水平滑动 tab 居中
能够左右滑动的 tabs 标签页,有时候需要将处于 active 状态的 tab 居中显示,效果如下
在线查看
html 文件如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>JS Bin</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<div class="slide-wrap" id="parent">
<div
v-for="(item,index) in tabList"
@focus="changeTab(index)"
:key="index"
:id="'item'+index"
tabindex="0"
:class="{item:true,'focus':activeIndex===index?true:false}"
>
{{item.name}}
</div>
</div>
</div>
</body>
</html>CSS 文件如下:
JS 文件如下:
Last updated
Was this helpful?