简体   繁体   English

获取内联列表项以溢出父级ul

[英]Get inline list items to overflow parent ul

I have a menu which is made as a list with inline items. 我有一个菜单,作为列表与内联项目。 While rendering correctly on large screens, elements move underneath the menu when the browser window gets smaller, instead of putting them to the right of the rest of the content. 在大屏幕上正确呈现时,当浏览器窗口变小时,元素会在菜单下移动,而不是将它们放在其余内容的右侧。

With min-width:100%; min-width:100%; for .drop_menu I was expecting that the menu would be 100% of the screen width at minimum, but stretch to fit more menu items in the x direction if necessary. 对于.drop_menu我原本期望菜单至少是屏幕宽度的100%,但如果需要,可以伸展以适应x方向的更多菜单项。

With width:500px; width:500px; for .drop_menu it works, but I didn't want to give the menu a fixed width. .drop_menu它的工作原理,但我不想给菜单一个固定的宽度。

The reason that I want the items to overflow in the x direction is because I was going to implement a javascript scroller so the menu would scroll when the mouse cursor gets close to the edge. 我希望项目在x方向上溢出的原因是因为我要实现一个javascript卷轴,所以当鼠标光标靠近边缘时菜单会滚动。 I can't scroll in the x-direction if there's no x-overflow. 如果没有x溢出,我无法在x方向滚动。

I've created a jsfiddle of my failing menu here: http://jsfiddle.net/j41jfjqL/3/ 我在这里创建了一个失败菜单的jsfiddle: http//jsfiddle.net/j41jfjqL/3/

Since they are inline, use white-space:nowrap to prevent the list items from appearing on a new line. 由于它们是内联的,因此请使用white-space:nowrap来防止列表项出现在新行上。

Updated Example 更新的示例

.drop_menu {
    white-space:nowrap;
}
.drop_menu > li {
    white-space:normal;
}

Since you don't want this to occur on the children li elements, set the white-space property value to normal . 由于您不希望在子li元素上发生这种情况,因此请将white-space属性值设置为normal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM