...

View Full Version : horizontal center div iside div



BubikolRamios
01-20-2008, 07:36 AM
style="float:left; must be there, how to horizontal center 'b' ?
This does not work, any ideas ?



<DIV style = "text-align:center;" >
<DIV>
<a style="float:left;">b</a>
</DIV>
</DIV>

BubikolRamios
01-20-2008, 07:49 AM
this works as long there is only one char of text, more characters does not work anymore
any other idea ?



<DIV style = " margin-left: 50&#37;;margin-right: 50%;">
<a style="float:left;">b</a>
</DIV>

abduraooft
01-20-2008, 07:49 AM
Your intention is not clear... please explain.

BubikolRamios
01-20-2008, 08:52 AM
style="float:left; must be there, because I have a bunch of things there instead of 'b'
but they doesn't get centered because of a tag float:left.

to get clear: want to center this code inside any div:



<a style="float:left;">b</a>


so far I got this, it works(FF, IE7), but I dont like this absolute 30 px stuff becuse:
1. b has variable length (px)
2. b can appear in variable length DIV tags.

Can this be done any other way ?



<DIV style = " margin-left: 30px;">
<DIV>
<a style="float:left;">b</a>
</DIV>
</DIV>

abduraooft
01-20-2008, 09:03 AM
style="float:left; must be there, because I have a bunch of things there instead of 'b'
This is not clear. Why do you need to use float for the above purpose. Even if you have many <a> elements to be displayed side by side, no need to use float, since <a> is an inline tag.

I think display:block is what you are looking for.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum