Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center a header image

Tags:

css

image

center

I have a problem. The answers to other people questions didn't solve my problem.

It's about image in my header, here's the code:

HTML

<div id="site">

    <div id="header">
        <img class="center" src="http://i.imgur.com/jfDhpP5.png"/>    
    </div>

    <div id="mainNav">
        <li><a href="#">one</a></li>
        <li><a href="#">two</a></li>
        <li><a href="#">three</a></li>
        <li><a href="#">four</a></li>
    </div>

</div>

CSS

#container{
    width: 1000px;
    margin: 1em auto;
}

#header{
    display: block;
    width: 1000px;
    margin: 0 auto;
}

body{    
    background-color: grey;
    color: black;
    font-family: sans-serif;
}

img.center{
    text-align:center;
    margin: 0 auto;
    padding:0px;
}

I also try this:

div#pictures {
  text-align: center;
}

also not working... checked in firefox and IE, the newest versions.... o.O

Please help!

like image 523
user3022396 Avatar asked Oct 23 '25 01:10

user3022396


1 Answers

CSS for header

width:100%;
text-align:center;

CSS for your img

display:inline-block;
margin: 0 auto;

See example here

That said, merely having text-align:center; on your header should be find, as in here

like image 140
SW4 Avatar answered Oct 24 '25 15:10

SW4