gpt4 book ai didi

html - max-width of 100px 和 width of 100px ,为什么 max-width 比 width 短?

转载 作者:行者123 更新时间:2023-11-28 03:07:50 25 4
gpt4 key购买 nike

我想了解这两者的区别 谢谢

最大宽度:100px image

宽度:100px image

body{
max-width: 1080px;
width: 1080px;
background-color: floralwhite;
margin:0px;
padding: 0px;
}

p{
width:100px; /* and max-width of 100px; */
padding: 20px;
margin:0px;
float:left;
}

最佳答案

您可以认为 width 属性比 max-width 属性更严格。

  • 宽度说:“你应该是这个宽度,没有其他。”
  • Max-width 说:“任何你想要的宽度,只要不大于这个宽度即可。”

您可以通过您提供的演示看到这一点。框的自然宽度约为 50px,不大于 100px,因此 max-width 并不关心。但是,width 发现框不是 100px,因此将它们设置为 100px。

关于html - max-width of 100px 和 width of 100px ,为什么 max-width 比 width 短?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45861446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com