April 21, 201412 yr I really didn't want to post a link to the site I'm building until it's more complete but I'm stuck on a problem. I'm using HTML5/CSS3 and I'm having problems getting the Menu and the Image centered (I haven't looked into the menu much, been mainly focused on the Image. Here is the Div class: #hero-image { display: block; width: 80%; max-width: 100% } The container surrounding the div mentioned above is: .container { width: 940px; padding: 0 10px; margin: 0 auto; } If I lower the percentage of the image width then it seems to go centered but I can't seem to figure out why I can't have the image bigger and centered. I thought It must be the padding after temporarily removing this it made no difference. Here is the site: http://edgar.ldn.kualo.net/~lmpmeuk/web/busybees/ HTML section: <header> <div class="container clearfix dashes-bottom"> <a href="/" title="Click here to go home" id="logo"> <img src="img/logo-main.png" alt="logo"> </a> </div> <div class="container clearfix"> <nav> <ul> <li><a href="/about">About</a></li> <li><a href="/products-and-prices">Products and Prices</a></li> <li><a href="/gallery">Gallery</a></li> <li><a href="/contact">Contact me</a></li> </ul> </nav> </div> <!--end container--> <div class="container clearfix"> <div id="hero-image"> <a href="/"> <img src="img/slider/kitchen_adventurer_cheesecake_brownie.jpg" alt="hero"> </a> </div> </div> <!--end hero container--> </header> I hope someone can help, Thanks. Edited April 21, 201412 yr by ~Luke
April 21, 201412 yr The hero image link - Remove those 3 styles and just give it a display of inline block. The container that this link resides in should have text-align center. As a side note anything that is a block element or has display block does not require a width or max width of 100% as width 100% is the browser default.
April 23, 201412 yr Author Thanks for the advice. I removed the 3 lines and did a display: inline; However it didn't center. I centered by doing a text-align: center; in the hero-image attribute - is this correct formatting? I tried doing the same for the nav but that didn't work so I tried on the ul and li entered within nav - no joy. Any idea's?
April 25, 201412 yr I don't have any suggestions, but I think Robert was saying inline-block rather than inline.
April 25, 201412 yr Remove float:left; on nav ul. Remove float: left; on nav ul li and add display: inline;
April 26, 201412 yr Author Thank Rbrt, Jane and Jack. I have sorted it now with the advice give. So for centering the header image I used text-align:center; in the container it was contained it. Just so I can get an understanding, why wouldn't it be the standard centering attribute of margin:0 auto; Thanks again.
Create an account or sign in to comment