Reputation:
I was just wondering if it's possible to give a div a width of auto (expandable) but also not allow it to expand more then x amount of pixels?
Upvotes: 0
Views: 104
Reputation: 37464
max-width: %/px/em/vh/vw,etc...
Also if you put max-width: 100%
on an image element, the image scales to fit its parent container. Ie. Responsive images
Upvotes: 1
Reputation: 725
Yep, you can use the style, max-width
div {
width: auto;
max-width: 100px;
}
Upvotes: 3
Reputation: 78650
You can use max-width
:
Be aware that certain version of IE don't support this (would have to look up which) and some I believe require a strict doctype.
Upvotes: 1