原内容来自 https://segmentfault.com/q/1010000003490547
在原基础上做了少量修改,避免当内容宽度小于容器宽度时,会出现横向滚动条。解决方法是:将横向滚动条溢出至容器外,保证横向滚动条不可见
<div class="inc-scroll-landscape-container">
<div class="inc-scroll-landscape-content">
<ul>
<li class="active">a</li>
<li>b</li>
<li>c</li>
<li>e</li>
<li>f</li>
<li>g</li>
<li>h</li>
</ul>
</div>
</div>
.inc-scroll-landscape-container { width: 100%; height: 50px; overflow: hidden; background-color: #FFF;}
.inc-scroll-landscape-container > .inc-scroll-landscape-content {
padding-bottom: 100px; /* 当内容宽度小于容器宽度时,会出现横向滚动条。将横向滚动条溢出至容器外,保证横向滚动条不可见 */
white-space: nowrap;
overflow: hidden;
overflow-x: scroll; /* 1 */
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-overflow-scrolling: touch; /* 2 */
text-align: justify; /* 3 */
&::-webkit-scrollbar { display: none;}
}
.inc-scroll-landscape-container > .inc-scroll-landscape-content > ul {}
.inc-scroll-landscape-container > .inc-scroll-landscape-content > ul > li { width: 60px; height: 50px; line-height: 50px;
position: relative; display: inline-block; text-align: center; font-size: 13px; color: #666; font-weight: bold;}
.inc-scroll-landscape-container > .inc-scroll-landscape-content > ul > li.active:after { position: absolute;
right: 16px; bottom: 8px; left: 16px; height: 5px;
background-color: #DD524D; content: ' '; transform: scaleY(0.5); -webkit-transform: scaleY(0.5);}
1 个回复
张一三