最大宽度会自动更改其值
我有一个关于最大宽度
的问题,为什么它会自行更改依赖范围。
这是我的代码:
div {
height: 100px;
max-width: 500px;
background-color: powderblue;
}
因此,最大宽度
为500px,但是当我调整显示大小时,max宽度
值更改。
在下图中,我的结果大小为150px宽度: 在此处输入映像
您可以看到我的部门宽度实际上是150px,而不是500px 最大宽度
值。
那么,为什么最大宽度
自动更改其值?说显示宽度是否小于最大宽度
,那么它与屏幕的宽度匹配是正确的吗?
干杯
I have a question about max-width
and why does it change itself Dependeds on display width.
here is my code:
div {
height: 100px;
max-width: 500px;
background-color: powderblue;
}
So the max-width
is 500px but when I resize my display size, max-width
value changes.
In the image below I have a result size with 150px width:
enter image description here
as you can see my division width is actually 150px, not 500px which was my max-width
value.
So why does max-width
automatically changed its value? Is it correct to say if the display width is smaller than max-width
, then it matches the width of screen?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用最大宽度,您告诉浏览器该元素的最大宽度是什么。
如果元素的最大宽度大于500px,它将使元素的高度更大。
使用最大宽度,您设置了最大宽度,因此它可能较小,但不大于500px
with max-width, you tell the browser what is max-width of the element.
if the max-width of the element is bigger than 500px it will make the height of the element bigger.
with max-width, you set the maximum width and therefore it can be smaller but not bigger than 500px
最大宽度确定元素可以拥有的最大宽度。这意味着您的元素可以获得每个宽度的宽度小于最大宽度。
您应该编写最小宽度以指定您期望的最小宽度。
并为确切的值写宽度。
Max-width determines maximum width which an element can have. It means your element can get every width less than your max-width.
You should write min-width to specify minimum width that you expect.
And write width for exact value.
最大宽度告诉元素不能超过该点,最小宽度告诉元素不能低于该值,因此,如果您希望元素不缩小或降低其宽度,请使用最小宽度
Max-width tells that the element cant exceed that point, min-width tells that the element cant be below the value, therefore use min-width if you want your element not to shrink or lower its width