h5页面实现一个内容区域可水平滚动的table

<script setup>
import smallTitle from "@/components/smallTitle.vue";
</script>

<template>
  <div class="home_container">
    <smallTitle title="绩效结果公示"> </smallTitle>
    <div class="table-container">
      <table>
        <thead>
          <tr>
            <th>工号</th>
            <th>姓名</th>
            <th>部门</th>
            <th>职务等级</th>
            <th>职务</th>
            <th>中心</th>
            <th>人员类型</th>
            <th>签证类型</th>
            <th>护照号码</th>
            <th>护照有效期</th>
            <th>差旅行程</th>
            <th>出差天数</th>
            <th>审批状态</th>
            <th class="thelastcolumn">操作</th>
            <!-- 可以继续添加更多列 -->
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>内容1</td>
            <td>内容2</td>
            <td>内容3</td>
            <td>
              sdhoisahdopsah地方GIS打更覅USD啊过户披萨回顾武器干哈放醋武器书发的宿管会粗判定为购房户王企鹅哦怕怕广发沪du
              海鲜凑陪我死得很惨哦is等哈 内容4
            </td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td>内容5</td>
            <td class="thelastcolumn1">
              <van-button
                :disabled="contractState"
                type="warning"
                size="mini"
                icon="eye-o"
              ></van-button>
            </td>
            <!-- 可以继续添加更多内容 -->
          </tr>

          <!-- 可以继续添加更多行 -->
        </tbody>
      </table>
    </div>
  </div>
</template>

<style scoped lang="scss">
.home_container {
  background-color: #f2f4f6;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.table-container {
  width: 100%;
  overflow-x: auto; /* 当内容超出容器宽度时显示水平滚动条 */
  -webkit-overflow-scrolling: touch; /* 优化移动端滚动体验 */
  margin-top: 20px;
  padding-bottom: 20px;
}

table {
  border-collapse: collapse;
  min-width: max-content; /* 让表格宽度至少等于其内容的宽度 */
}

th {
  color: #ffffff;
  text-align: center;
  font-family: "Source Han Sans CN";
  font-size: 22px;
  font-style: normal;
  font-weight: 400;
  background-color: #0057c8;
  height: 75px;
}

th,
td {
  padding: 8px 12px;
  max-width: 300px;
  text-align: center;
  font-family: "Source Han Sans CN";
  font-size: 22px;
  font-style: normal;
  font-weight: 400;
}

.thelastcolumn {
  position: sticky;
  right: 0;
  background-color: #0057c8; /* 确保背景颜色一致 */
  z-index: 1; /* 确保在滚动时不会被其他内容遮挡 */
}
.thelastcolumn1 {
  position: sticky;
  right: 0;
  z-index: 1; /* 确保在滚动时不会被其他内容遮挡 */
//   background-color: #e7f0fe;
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

捂風鋔笶_小欣同學

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值