[英]HTML CSS LI Wrapping
I have a vertical menu in my system which is basically made of HTML ul
/ li
with CSS styling (see image below). 我的系统中有一个垂直菜单,它基本上由带有CSS样式的HTML
ul
/ li
(见下图)。 However I don't want the li
items which are wider than the menu to wrap, I would prefer them to overflow with a horizontal scroll bar at the bottom of the menu. 但是我不希望比菜单更宽的
li
项目换行,我希望它们在菜单底部有一个水平滚动条溢出。 How can I do this in CSS? 我怎么能在CSS中这样做?
ul {
overflow: auto; // allow li's to overflow w/ scroll bar
// at the bottom of the menu
}
li {
white-space: nowrap; // stop the wrapping in the first place
}
Use white-space:nowrap
. 使用
white-space:nowrap
。 Like so: 像这样:
li {
white-space:nowrap;
}
Here's some documentation . 这是一些文档 。
You would also need to give the style the ul: 你还需要给样式ul:
ul{
width:250px;
overflow:auto;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.