宽度:100%vs最大宽度:100% [英] width:100% vs max-width: 100%

查看:100
本文介绍了宽度:100%vs最大宽度:100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

宽度:100%和最大宽度:100%可以互换使用,如果它们中的任何一个仅用于一次?



例如,我得到相同的结果:

  img {
width:100%;

$ / code $ / pre



  img {
max-width:100%;
}

我在这里错过了什么?


Could width:100% and max-width:100% be used interchangeably if any of them is used just once?

For example I get the same results with:

img{
    width:100%;
}

and with:

img{
    max-width:100%;
}

Am I missing something here?

解决方案

If your images are always larger than the element they are within the two rules will appear to behave the same. If an img is smaller than the parent element than the first rule will stretch it to the full width of its parent. The second rule will not.

这篇关于宽度:100%vs最大宽度:100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆