我有一个响应式 UL List ,许多 Li ImageItem 和 span 都在这个 UL 中。 在最大化尺寸时,3 个元素显示在一行中,当我调整(小)我的浏览器时,2 个元素显示并且工作正常。但是在我的浏览器的最小尺寸中出现水平滚动 :( 1 项显示但滚动出现,我如何防止水平滚动?! 这是我的 CSS :
.myUl {
font-size:large !important;
color:#373636 !important;
text-align:center !important;
}
.myUl li {
width:350px !important;
}
.myUl li:hover {
background:rgba(0, 0, 0, 0.2) !important;
}
.myUl li img {
height:170px !important;
width:100px !important;
}
.myUl li span {
float:right !important;
width:170px;
padding-right:8px !important;
padding-top:10px !important;
text-align:right !important;
vertical-align:middle !important;
line-height: 1.5em !important;
}
ul.img-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.img-list li {
display: inline-block;
height: 180px;
margin: 0 1em 1em 0;
position: relative;
width: 150px;
}
ul.img-list li:hover span.text-content {
opacity: 1;
}
这是我的 Index.cshtml
<div>
<ul class="img-list myUl">
<li>
<span>
some text here
</span>
<span style="float: left !important; padding-top: 3px !important;">
<a>
<img class="img-responsive img-circle img-thumbnail" src="~/Images/MenuImages/z.jpg" />
</a>
</span>
</li>
<li>
.........
</li>
</ul>
我页面的图片
最佳答案
为了防止水平滚动,只需将其添加到 Css 中的 body 标签中即可:
body {
overflow-x: hidden;
}
希望对您有所帮助
关于html - 如何防止 Bootstrap 和列表中的水平滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33864615/