1

Hello I have a logo on my website that I just can't seem to get centered. My css for the logo is as follow,

@media only screen and (min-width: 768px) {
    #logo {
        float: none;
        margin: 0 auto;
        width: 768px;
    }
}

http://www.questdesign.com.au/

Any chance you might know what i'm missing? Any help would be great. Thanks.

areim
  • 3,371
  • 2
  • 23
  • 29
Endô Fujimoto
  • 313
  • 1
  • 5
  • 15

5 Answers5

5

Try text-align:center;

@media only screen and (min-width: 768px) {
    #logo { float: none; margin: 0 auto; width: 768px; text-align:center; }
}
Ionut Necula
  • 11,107
  • 4
  • 45
  • 69
4

img is inline tag, so it will not work even though you add margin:auto. Add property display:block, it will make img as block level element and margin:0 auto; will make it as center.

Your code will be

@media only screen and (min-width: 768px) {
    #logo { float: none; margin: 0 auto; width: 768px; display:block;}
}
Laxmikant Dange
  • 7,606
  • 6
  • 40
  • 65
1

You can add a text-align:center; to the parent div and the width you want to have the image centered in (100% eg) removing the margin 0 auto

Martijn de Langh
  • 405
  • 3
  • 16
1

img is inline tag so you need either change display:block and then margin: 0 auto or in parent tag put text-align:center

Robert
  • 19,800
  • 5
  • 55
  • 85
0

You can try using flexbox to your logo container.

#logo{
    width:800px;
    display: flex;
    border: 1px solid black;
    align-items: center;
    justify-content: center;
    text-align: center;
}

Example here:
https://jsfiddle.net/86n9qb7b/

AeroX
  • 3,387
  • 2
  • 25
  • 39
Shishibi
  • 53
  • 10