![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm having trouble getting the menu below to centre horizonatally. I've tried putting it into a container div and using text-align:center; I've tried margin:auto and margin-left:auto & margin-right:auto; I've even tried the deprecated <center> tag. None of it works. I'm assuming it either has to do with the display:block (which I need to keep the 'button look') or with the float:left. |
#3
| |||||||
| |||||||
|
|
Sentient Fluid wrote: I'm having trouble getting the menu below to centre horizonatally. I've tried putting it into a container div and using text-align:center; I've tried margin:auto and margin-left:auto & margin-right:auto; I've even tried the deprecated <center> tag. None of it works. I'm assuming it either has to do with the display:block (which I need to keep the 'button look') or with the float:left. |
Of course I could be wrong, too. ![]() So what am I missing? Here's the link: http://www.geocities.com/sentientfluid/test2.html |

|
Padding and margin would hep center the link division setup. |
|
text-align is just that. For text, not the division. |
|
Also, I'd avoid using "center" as a class name. |
|
icenter would be better. |
|
just so that the script doesn't get confused as to which is which. |
#4
| |||
| |||
|
|
"Richard" <Anonymous (AT) 127 (DOT) 001> wrote: Sentient Fluid wrote: I'm having trouble getting the menu below to centre horizonatally. I've tried putting it into a container div and using text-align:center; I've tried margin:auto and margin-left:auto & margin-right:auto; I've even tried the deprecated <center> tag. None of it works. I'm assuming it either has to do with the display:block (which I need to keep the 'button look') or with the float:left. It's with the float: left; Floated elements will float to the specified side. http://www.geocities.com/sentientfluid/test2.html You've given each link a fixed width. This is a bad idea in general (increase the font size in your browser and watch things fall apart) but this does mean that you can center the links: .center {width: 744px; margin-left: auto; margin-right: auto; } But as we don't want the width to be in pixels we can change everything to use em instead. Say width: 7.5em (and height: 1.5em ![]() for the links and width: 50em; for the division). It's not a perfect solution but with the poor support for CSS tables and the inline-block/table display values it may be one of the least worst ones. Something like navbar would be a sensible class name for a navigation bar. |

#5
| |||
| |||
|
|
Steve Pugh wrote: Sentient Fluid wrote: http://www.geocities.com/sentientfluid/test2.html You've given each link a fixed width. This is a bad idea in general (increase the font size in your browser and watch things fall apart) but this does mean that you can center the links: .center {width: 744px; margin-left: auto; margin-right: auto; } But as we don't want the width to be in pixels we can change everything to use em instead. Say width: 7.5em (and height: 1.5em ![]() for the links and width: 50em; for the division). It's not a perfect solution but with the poor support for CSS tables and the inline-block/table display values it may be one of the least worst ones. Thanks for the help, Steve. I've changed the fixed widths to variable widths. When I was trying to get things centered before I posted, I totally forgot to set the width when using margin-left:auto and margin-right:auto. Problem is it doesn't work in IE. At least not 6.0. It does, however, work in Firefox. I still need to install some other browsers to test it in, though... |
|
One thing I noticed after making the changes, though. In Firefox, the buttons no longer wrap to the next line if the viewport is smaller than the width of the nav bar. Is there a way I can get that back and still maintain the centering? |
|
You mentioned above that it's not a perfect solution. How would you do what I'm bumbling around at? ![]() |
#6
| |||
| |||
|
|
I'm having trouble getting the menu below to centre horizonatally. I've tried putting it into a container div and using text-align:center; I've tried margin:auto and margin-left:auto & margin-right:auto; I've even tried the deprecated <center> tag. None of it works. I'm assuming it either has to do with the display:block (which I need to keep the 'button look') or with the float:left. Of course I could be wrong, too. ![]() So what am I missing? Here's the link: http://www.geocities.com/sentientfluid/test2.html |
![]() |
| Thread Tools | |
| Display Modes | |
| |