开发者

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

开发者 https://www.devze.com 2023-04-07 00:35 出处:网络
I was just wonder开发者_JAVA百科ing 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?Yep, you can use the style, max-width

I was just wonder开发者_JAVA百科ing 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?


Yep, you can use the style, max-width

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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消