Max-width

The element width is set to the value of min-width whenever min-width is larger than max-width or whenever min-width is larger than width . —-MDN
意思是说元素的width最终值是由min-width决定的

 1.给图片设置max-width后,当浏览器窗口小于max-width的时候不会出现横向的滚动条

 2.max-width的值会覆盖width的值当浏览器的窗口小于width值的时候,即使width的值设置在inline-class里

 例如:
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <style>
        img {
            max-width: 100%;
            height: auto;
        }
    </style>
</head>
<body>
<p>
    <b>缩小浏览器的窗口,img的width值是跟着窗口大小改变</b>
</p>
<img src="http://www.w3schools.com/css/img_chania.jpg" alt="Chania" style="width: 900px"/>  
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值