hollys84 Posted September 18, 2012 Share Posted September 18, 2012 So this is what i have so far <div class="cleared"></div></div> <div class="container08"> <h2>Small</h2> <p>Here comes your content</p> </div> <div class="container08"> <h2>Medium</h2> <p>Here comes your content</p> </div> <div class="container08"> <h2>Large</h2> <p>Here comes your content</p> </div> my problem is i cant get it to align in the center of my page...... Anyone have any ideas they can give me? Much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/ Share on other sites More sharing options...
floridaflatlander Posted September 18, 2012 Share Posted September 18, 2012 What do you want aligned? Usually if you want to center h2 .container08 h2{text-align: center;} on the style sheet or in the header or <h2 style="text-align: center;">small</h2> and ... added if you want to center container08 .container08 { width: 50%; /* or what ever*/ margin: 0 auto; } Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379112 Share on other sites More sharing options...
hollys84 Posted September 18, 2012 Author Share Posted September 18, 2012 .container08 { background-color: #666; float: left; height: 115px; width: 180px; border-radius: 200px; text-align: center; overflow: hidden; border: 10px solid #03C; margin: 0px; padding-top: 65px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; box-shadow: inset 0px 10px 5px #111, inset 0px -5px 5px #111, 0px 3px 10px #FFF; } .container08 p { color: #FFF; margin: 0px; text-shadow: 0px -1px 1px #000, 0px -1px 1px #000; } .container08 h2 { font-size: 24px; color: #03C; margin: 0px; text-shadow: 0px -2px 0px #006; } Thats the css for it basically its three circle containers that at the moment are to the far left i wanna move the all three to the center without putting them on seperate lines if that makes any sense Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379113 Share on other sites More sharing options...
floridaflatlander Posted September 18, 2012 Share Posted September 18, 2012 Well you know that the total width of the container is the width plus padding plus border plus margin don't you? With that in mind float all divs left add a width that fits and play with the height if needed. Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379115 Share on other sites More sharing options...
floridaflatlander Posted September 18, 2012 Share Posted September 18, 2012 If your going to do stuff like this get and use firefoxes firebug, firebug color codes the divs, margins, borders and padding on the web page so you can see the styles, it will tell you what the css file name is, the name of the style, what line the style is coming from and the inheritance if any. I think chrome does the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379117 Share on other sites More sharing options...
hollys84 Posted September 18, 2012 Author Share Posted September 18, 2012 I always use chrome but thank you for the advice Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379119 Share on other sites More sharing options...
wickedXxxxlegox Posted September 18, 2012 Share Posted September 18, 2012 @holly, DO NOT use what everyone else has been saying. Just use <center> and </center> Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379126 Share on other sites More sharing options...
Mahngiel Posted September 18, 2012 Share Posted September 18, 2012 @holly, DO NOT use what everyone else has been saying. Just use <center> and </center> Why? and for what authority do you say that? text-align:center; is much more semantic and appropriate Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379130 Share on other sites More sharing options...
Adam Posted September 18, 2012 Share Posted September 18, 2012 @holly, DO NOT use what everyone else has been saying. Just use <center> and </center> <center> is deprecated, and alone wouldn't achieve what the OP is after. You're much better off using display: inline-block on each of the .container08 elements, with a parent element containing text-align: center. Unfortunately this isn't supported in older browsers, so there's a few little hacks you need to include. Created this to demonstrate: http://jsfiddle.net/EcPcw/ Ensure the last four properties remain in that order. Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1379138 Share on other sites More sharing options...
matthewtbaker Posted October 8, 2012 Share Posted October 8, 2012 Hi Holly, To centre a DIV simply set the margin to: margin: 0 auto; I would strongly advise against wickedXxxxlegox's suggestion of using <center></center> as this merges content and styling which isn't best practice. Matt Quote Link to comment https://forums.phpfreaks.com/topic/268530-lost-on-how-to-align/#findComment-1383700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.