我只用 CSS 完成了一些滚动指示器。这几乎在任何地方都有效,而且很棒。唯一的问题是,如果盒子没有溢出(第一个盒子),那么盒子的内容就不会向左对齐。有什么想法如何做到这一点?另外:请随意使用此代码:)
html {
background: #FFF;
}
.scrollbox ul {
white-space: nowrap;
-webkit-box-flex: 1;
-webkit-flex: 1 0 auto;
-ms-flex: 1 0 auto;
flex: 1 0 auto;
margin-left: -4rem;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
list-style-type: none;
}
.scrollbox {
outline: 1px dotted black;
position: relative;
z-index: 1;
overflow-x: auto;
overflow-y: hidden;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap; …Run Code Online (Sandbox Code Playgroud)css ×1