[英]Using the min-width in CSS
i am having problems with using the min-width; 我在使用最小宽度时遇到问题; code in CSS,
CSS中的代码,
I have a menu bar that i would like to fix so it doesn't decrease in width as the browser size changes, my problem is that when i try min-width:1000px; 我有一个菜单栏,我想修复,所以它不会随着浏览器大小的变化而减小,我的问题是,当我尝试min-width:1000px; this doesn't work,
这不起作用,
Please will you take a look at my CSS and see if there are any errors, 请你看看我的CSS,看看是否有任何错误,
CSS: CSS:
#bar {
margin-top:55px;
min-width:1000px center;
max-width:1920px;
height: 30px;
background: #2E2E2E;
border: 3.2px groove #FFD700;
min-width:1000px; }
Thankyou for your help 谢谢您的帮助
remove this min-width:1000px center;
删除此
min-width:1000px center;
and have your css like this for the widths 和你的CSS这样的宽度
#bar {
max-width:1920px;
min-width:1000px;
width: 100%;
}
I just tried out your css, and it stays 1000px wide even in a tiny window. 我刚尝试了你的css,它甚至在一个小窗口中也保持1000px宽。 You could try to remove one of the min-width you have declared, I suggest the first one.
您可以尝试删除您声明的最小宽度之一,我建议第一个。
That's happening because your div is using the max-width
property. 发生这种情况是因为你的div正在使用
max-width
属性。
Try to use the width
based on percentage and you'll understand the power of min
and max
width. 尝试使用基于百分比的
width
,您将了解min
和max
宽度的功效。
#bar {
margin-top:55px;
max-width: 500px;
width: 100%;
height: 30px;
background: #2E2E2E;
border: 3.2px groove #FFD700;
min-width: 300px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.