当前位置:Gxlcms > html代码 > div中ulli超出宽度隐藏且li不换行_html/css_WEB-ITnose

div中ulli超出宽度隐藏且li不换行_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:14人阅读

  1. <style> ul { list-style-type: none; } li { float: left; display: inline-block; display: -moz-inline-stack; display: inline; } </style><div style="width: 500px; margin: auto; border: 1px solid red; overflow: hidden; line-height: 30px; height: 30px;"> <span style="float: left"><</span> <ul> <li>1111111111111111111</li> <li>22222222222222</li> <li>33333333333333333333</li> <li>444444444</li> </ul> <span style="float: right">></span> </div>


想要实现的是 让li横向排列。当ul的的内容溢出div时隐藏。 并且点击 <与 >时 可以移动ul 显示出被隐藏的内容。

现在是 给ul li 加上position ul中li内容溢出时 不会换行 但是也隐藏不掉。 不加position 可以隐藏。但是会换行。
求教高手。


回复讨论(解决方案)

  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style>
  2. ul{margin:0;padding:0;}
  3. li{list-style:none;}
  4. .box{width: 500px; margin: auto; border: 1px solid red; overflow: hidden;line-height: 30px; height: 30px; position:relative;}
  5. .box ul li{float:left;display:inline; vertical-align:top;height:30px;line-height:30px;padding:0 5px;}
  6. .box ul {position: absolute;}
  7. .box span{float:left;height:100%;line-height:30px;font-size:16px;background:#ccc;width:30px;text-align:center;}
  8. .menu{float:left; width:440px;overflow:hidden; height:30px; position:relative;}
  9. </style>

人气教程排行