user849137
user849137

Reputation:

is it possible to make a div width auto BUT now more than x pixels/inches? in CSS

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

Answers (3)

benhowdle89
benhowdle89

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

Aaron Dougherty
Aaron Dougherty

Reputation: 725

Yep, you can use the style, max-width

div {
    width: auto;
    max-width: 100px;
}

Upvotes: 3

James Montagne
James Montagne

Reputation: 78650

You can use max-width:

http://jsfiddle.net/CssJJ/

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

Related Questions