BleepingComputer.com: Div Boxes and centering

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Div Boxes and centering so hard! lol

#1 User is offline   crumbs744 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 19
  • Joined: 07-September 08

Posted 27 April 2009 - 01:25 AM

Still doing a website for a big client, its been jumping ahead in leaps and bounds which is really great and i have having a good time learning php and css, recently hit a few speed bumps in unlikely places, such as vertically positioning text in div boxes (i didn't think it would be so complicated) now im having trouble getting divs to center and float and the same time.
here is the url.

http://www.humanresources.com.au/jit/OHR%2...;page=flowchart

this 'flowchart' is just a bunch of small div boxes that are hyperlinked that take you to an appropriate page.

i need to have them centered and spaced out nicely, the row on the top is pretty much how it should look, only at the moment if it had three buttons they would all float to the right, of left, im not sure which.

the 2nd row in the other hand centers buttons how i need them, but without the float property it wont line up horizontally.

Hope you guys know what im talking about.

First row.
div.rowone	{
	text-align: center;
	float: right; 
	position:relative; 
	margin:auto; 
	border: thin solid #000; 
	height:52px; 
	width:auto;
	}


div.rowtwo	{
	position:relative; 
	top:100px;
	border: thin solid #000; 
	height:52px; 
	}


(you'll be pleased to know i have indented like you told me i should last time)


Thanks heaps!!

#2 User is offline   Samsbc12 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 89
  • Joined: 08-April 08
  • Gender:Male

Posted 27 April 2009 - 08:35 PM

http://www.jakpsatweb.cz/css/css-vertical-...r-solution.html is a good tutorial for centering vertically.

#3 User is offline   KamakaZ 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 557
  • Joined: 26-August 08
  • Gender:Male
  • Location:Victoria

Posted 27 April 2009 - 10:29 PM

Why not try something like this?

I know this is for tables, but you might be able to mod it for a div...

<table align="center" height="100%" width="100%">
<tr>
<td valign="middle" align="center">&nbsp;</td>
</tr>
</table>


Good luck!
If I am helping you and don't reply in 24 hours please send me a PM

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.

#4 User is offline   crumbs744 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 19
  • Joined: 07-September 08

Posted 28 April 2009 - 08:16 PM

I have tried to align it in the HTML, (even though it isn't valid), but for some reason it still wont happen for me, i haven't resorted to tables yet, my boss likes to make things difficult. i need a css soloution.

Thanks though kamaka7.

and samsbc12 i need to have them horizontally centered, vertically i have got it working fine.

#5 User is offline   webrat 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 100
  • Joined: 08-April 08
  • Gender:Male

Posted 01 May 2009 - 08:42 AM

Have you tried using the CSS Margin property other than on auto? You should be able to move the divs around virtually at will as long as you obey a few simple rules - watch out for total widths of content, padding and margins combined as this could 'break' the page. If they are floated they need to be put in your HTML in the correct order otherwise you weill get unexpected results - it usually works right-left-right-left and so on, as many as you like. Make small changes you can keep track of. Validate the changes to avoid unexpected errors cascading into sleepless nights lol.

This post has been edited by webrat: 01 May 2009 - 12:25 PM


#6 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 01 May 2009 - 01:26 PM

Take a look at this:

body {
margin-left:10%;
margin-right:10%;
}

#header {
width:30%;
background:black;
height:280px;
float:left;
}


#header-right {
width:50%;
background:black;
height:280px;
float:left;
}

#content {
width:80%;
background:black;
float:left;
}

#footer {
width:80%;
background:black;
float:left;
}

p {
color:white;
font-family:Arial;
margin:8px;
}

a {
color:white;
font-family:Arial;
margin:8px;
border:0px;
}


I recently had the same problem, try using margin for the left and right, not the most orthodox method but hey it works...

Hope this helps, Wolfy87.

#7 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 08 May 2009 - 09:08 AM

I was just speaking to someone on the topic, i think this will solve your problem:

<style type="text/css">
<!--
div.maincontainingdivetc {
width:800px;
height:200px;
margin:0 auto;
}
-->
</style>


Set the width to whatever you like and change the div name, i just used that dumb name for an example but that will center a 800 x 200 div...

Hope this helps, Wolfy87.

#8 User is offline   crumbs744 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 19
  • Joined: 07-September 08

Posted 12 May 2009 - 11:31 PM

Hey good news, my boss finally relented and let me use table.
which i think is the easiest way around this and the customer then doesn't get charged for me googling and bleeping for the answers.

Again, thanks for the help. this has been a pretty big project for me in my spare time and i appreciate the help.

#9 User is offline   KamakaZ 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 557
  • Joined: 26-August 08
  • Gender:Male
  • Location:Victoria

Posted 13 May 2009 - 01:09 AM

haha, good old bosses... good luck with it all
If I am helping you and don't reply in 24 hours please send me a PM

There's no place like 127.0.0.1
There are 10 types of people in the world, those that can read binary, and those who can't.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users