设为首页 加入收藏

TOP

原生 table css实现操作按钮固定右侧及底部滚动 IE不会卡死
2019-09-02 23:37:46 】 浏览:12
Tags:原生 table css 实现 操作 按钮 固定 右侧 底部 滚动 不会 卡死

需求的表格比较复杂(各种合并新增删除),elementUi的table组件无法满足需求,故而写了原生table,且与其他用了table组件的表格保持一致。

 

贴一下简单的代码,只实现操作按钮固定右侧以及底部滚动条功能:

  

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
  width: 600px;
  margin: 100px auto;
}
.fixedOper {
  background-color: #fff;
  position: absolute;
  z-index: 100;
  top: 0;
  right: 0;
  width: 104px;
  height: 68px;
}
th,
td {
  border: 1px solid #000;
  height: 30px;
}
</style>
</head>

<body>
  <!-- 第一层DIV固定宽度与定位 -->
  <div style="width:100%;overflow-x: hidden;position: relative;">
    <!-- 底部滚动条及样式 -->
    <div style="width:100%;overflow-x: scroll;">
      <!-- 表格宽度需大于父盒子的宽度才会出现滚动条 -->
      <table style="width:120%;text-align: center;border-collapse: collapse;">
        <thead>
          <tr>
            <th>1</th>
            <th>2</th>
            <th>3</th>
            <th style="position: absolute;z-index: 1000;right: 0;top:-0.5px;
              width: 100px;">操作</th>
            <th style="width:80px;"></th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>测试</td>
            <td>测试</td>
            <td>测试</td>
            <td style="position: absolute;z-index: 1000;right: 0;top:33px;
              width: 100px;">编辑</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</body>
<script>
</script>
</html>
 
 
  这里用div包裹table写定位的样式而不是直接在table上直接写定位,是为了避免IE浏览器卡死
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇CSS样式 下一篇第十一课 CSS介绍与font字体 css..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目