I'm creating a flexible grid website and I ran into a snag. It doesn't appear that the CSS property max-width:100%;
is working on my logo image. It's supposed to resize along with the flexible grid, but it's not. Maybe I'm not calling the image correctly or my syntax is incorrect? The image is 200x67, and here's the relevant HTML:
<header>
<img src="images/so_200.png" alt="Website.com" id="logo" />
</header>
and here's the CSS for that:
header {
background-color:#ccc;
padding:1%;
}
img #logo {
display: block;
max-width:100%;
max-height:100%;
width: auto;
height: auto;
}
Any idea why it's not working? It shouldn't matter the image is a .png, right?
Remove space between img
and #logo
img#logo {
display: block;
max-width:100%;
max-height:100%;
width: auto;
height: auto;
}
Image file type(png) doesn't matter for css rules.
You have a space between the id and element:
img #logo => img#logo
img#logo {
display: block;
max-width:100%;
max-height:100%;
width: auto;
height: auto;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.