Reputation:
I'm applying max-width
to a div containing an image, but the image ignores the applied value.
Screenshot:
Snippet:
.screenshot {
max-width: 460px;
margin: 27px;
}
.description {
max-width: 705px;
}
<div class="screenshot">
<img src="http://placehold.it/850x850" alt="App">
</div>
<div class="description">text you see in screenshot.
</div>
Upvotes: 1
Views: 1965
Reputation: 46
The max-width would have to be on the image.
Image elements don't care what dimensions their parent tells them--they will simply stretch the parent container to fit anyways.
Edit: for example, you can create a new rule whose selector is .screenshot img and then apply the max-width there.
Edit If you try this rule with ids it won't work, it only works with classes.
Upvotes: 2
Reputation: 602
Here are some options you can try
Upvotes: 0