Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: resizing logo while maintaining aspect with browser

#logo {
    background: url(/images/logo.png) 0 0 no-repeat;
    width: 268px;
    height: 96px;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

This is my logo css and when I change the height and width to x% It just cuts of the bottom and right side of my logo image. How can I style my logo so that it stays at 5% of the browser width while maintaining aspect? Thanks

like image 495
colbern Avatar asked Sep 27 '26 19:09

colbern


1 Answers

Your image has to be an <img> tag, not a background, and the CSS of this <img> tag :

#logo_img{
    width:5%;
}

assuming the parent of #logo_img is 100% in width.

like image 81
darma Avatar answered Sep 30 '26 08:09

darma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!