<ul class="tab_ul">
<li class="tab_li" @click="changeTab(item, index)" :class="{'tabActive': tabActive == index}"
v-for="(item, index) in tabList" :key="index" v-cloak>{{ item.name }}</li>
</ul>
.tab_ul {
display:-webkit-box; /* iOS 6-, Safari 3.1-6 */
display:-webkit-flex; /* Chrome */
display:-moz-box; /* Firefox 19 */
display:-ms-flexbox;
display:flex; /*flex容器*/
height: 100%;
width: 100%;
overflow-x: scroll;
}
.tab_li {
position: relative;
font-size: 16px;
color: #bcc1d0;
font-weight: 600;
text-align: center;
line-height: 40px;
margin-right: 10px;
}
.tab_li:last-child {
margin-right: 0px;
}
```
###### 数据超出li宽度时会换行

###### 在超出的标签添加 white-space: nowrap;(文本不会换行,文本会在在同一行上继续),详情:[http://w3c0.com/cssref/136491](http://w3c0.com/cssref/136491)
```
.tab_li {
position: relative;
font-size: 16px;
color: #bcc1d0;
font-weight: 600;
text-align: center;
line-height: 40px;
white-space: nowrap;
margin-right: 10px;
}
```

### 捡了芝麻、丢了西瓜
flex 布局循环数据超出范围滚动条(内容不换行)
最新推荐文章于 2025-04-02 15:29:13 发布