加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 综合聚焦 > 编程要点 > 语言 > 正文

运用CSS怎么样做滚动表格的效果?

发布时间:2023-08-21 14:27:01 所属栏目:语言 来源:
导读:这篇文章给大家分享的是用CSS怎么样做滚动表格的效果的示例。小编觉得挺实用的,因此分享给大家做个参考,文中的示例代码介绍得很详细,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。

<template>
这篇文章给大家分享的是用CSS怎么样做滚动表格的效果的示例。小编觉得挺实用的,因此分享给大家做个参考,文中的示例代码介绍得很详细,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。
 
<template>
 
  <section>
 
    <div class="box">
 
      <ul class="header">
 
        <li class="cell">序号</li>
 
        <li class="cell">姓名</li>
 
        <li class="cell">年龄</li>
 
        <li class="cell">性别</li>
 
        <li class="cell">专业</li>
 
      </ul>
 
      <div class="body">
 
        <ul class="list">
 
          <li
 
            v-for="(item, index) in arr"
 
            :key="index"
 
            class="row"
 
          >
 
            <span class="cell">{{ item }}</span>
 
            <span v-for="(n) in 4" :key="n*30" class="cell">{{ n }}</span>
 
          </li>
 
        </ul>
 
      </div>
 
    </div>
 
  </section>
 
</template>
 
<script>
 
export default {
 
  data() {
 
    return {
 
      arr: [],
 
    }
 
  },
 
  created() {
 
    this.arr = Array.from(new Array(20), (v, k) => {
 
      return k + 1
 
    })
 
    // 表格显示5行数据,此处复制开头的5条数据实现无缝
 
    this.arr = this.arr.concat(this.arr.slice(0, 5))
 
  }
 
}
 
</script>
 
<style lang="scss">
 
$cellHeight: 30px;
 
ul {
 
  list-style: none;
 
  margin: 0;
 
  padding: 0;
 
}
 
.box {
 
  width: 60%;
 
  margin: auto;
 
}
 
.header {
 
  display: flex;
 
}
 
.body {
 
  height: 5 * $cellHeight;
 
  overflow: hidden;
 
  // padding-bottom: 10px;
 
  li {
 
    display: flex;
 
    height: $cellHeight;
 
  }
 
}
 
.cell {
 
  flex: 1;
 
  height: $cellHeight;
 
  line-height: $cellHeight;
 
  border: 1px solid #e2e2e2;
 
  box-sizing: border-box;
 
}
 
.list {
 
  animation: scroll 10s  linear infinite;
 
  position: relative;
 
}
 
@keyframes scroll {
 
  from { top: 0; }
 
  to { top: -20 * $cellHeight }
 
}
 
</style>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章