[英]How to wrap UL list - LIs on new line with css
Here in the image below the list is going out of the screen. 在下面的图像中,列表将离开屏幕。 I need to block the width of the ul.
我需要阻止ul的宽度。 Width applied but going out of the ul width.
应用宽度但超出ul宽度。 Current CSS Used:
使用的当前CSS:
.menu ul{
width:100%;
max-width:100%;
}
Try this 尝试这个
.menu li {
display: inline-block;
}
Decent support and here's a nice round up . 体面的支持 ,这是一个很好的回合 。
If there's a 如果有的话
margin-left
try not to set the width to 100%
, but rather 100% - margin-left-value
margin-left
尽量不将宽度设置为100%
,而是将100%
设置为100% - margin-left-value
padding-left
use box-sizing: border-box
padding-left
使用box-sizing: border-box
If you don't have to support older browsers or are fine with loading a polyfill, flexbox model would do the job. 如果您不必支持旧版浏览器或者无法加载polyfill,那么flexbox模型就可以完成这项工作。
display: inline; 显示:内联; or display: inline-block;
或显示:inline-block;
Both works. 两者都有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.