如何将边框半径应用于具有水平滚动的分隔表行? [英] How to apply border radius to separated table rows that has horizontal scroll?

查看:19
本文介绍了如何将边框半径应用于具有水平滚动的分隔表行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大量数据的表格,所以它必须水平滚动.我已经设计了将每一行分隔为每张单独卡片的表格,但我无法正确获得表格行左右部分的边框半径.如果我滚动到右侧的尽头,那么我可以看到右侧的半径和左侧的半径相同.当您在中间时,您看不到任何边界半径.

PS:当有水平滚动时,将半径应用于第一个和最后一个 td 不起作用.:(

有什么技巧可以解决这个问题,让边界半径的两侧始终可见吗?我对桌面没有太多想法,因为它确实需要有限的属性.或者我们可能需要 javascript 来获得所需的输出?

我在下面的图片中看起来是这样的,

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}tbody tr::after {内容: '';宽度:100%;位置:绝对;左:0;右:0;背景颜色:#fff;高度:48px;z-index:0;边框半径:8px;}身体td {z-index:1;}

<html lang="en" class=""><头><meta charset="UTF-8"><title>演示</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"></头><身体><div class="page-wrapper"><div class="容器 pt-3"><div class="table-responsive">

解决方案

这是一个使用 position:sticky 的技巧,它似乎只在 Chrome 上运行良好(使用 firefox 检查).

tbody tr::after,tbody tr::before {内容: '';显示:块;位置:粘性;右:0;/* 一个会粘在右边 */左:0;/* 左边的另一个 */盒子阴影:30px 0 0 6px #f1f2f5;/* 一个盒子阴影来隐藏外部 */高度:48px;左边距:-50px;/* 对于你将使用的半径足够大 */z指数:9;边框半径:0 30px 30px 0;/* 你的半径 */}tbody tr::before {边距右:-50px;左边距:0;盒子阴影:-30px 0 0 6px #f1f2f5;边框半径:30px 0 0 30px;}thead tr::after,头 tr::before {内容:"";显示:块;}身体td {背景:#fff;}

完整代码:

var wrapper = document.querySelector("tbody");var myHTML = '';for (var i = 0; i <5; i++) {myHTML += '<tr>'+'<td>1</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>UKS127398SLA</td>'+'<td>2020-12-12</td>'+'<td>2020-12-12</td>'+'</tr>';}wrapper.innerHTML = myHTML;

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}tbody tr::after,tbody tr::before {内容: '';显示:块;位置:粘性;右:0;左:0;盒子阴影:30px 0 0 6px #f1f2f5;高度:48px;左边距:-50px;z指数:9;边框半径:0 30px 30px 0;}tbody tr::before {边距右:-50px;左边距:0;盒子阴影:-30px 0 0 6px #f1f2f5;边框半径:30px 0 0 30px;}thead tr::after,头 tr::before {内容:"";显示:块;}身体td {背景:#fff;}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"><div class="page-wrapper"><div class="容器 pt-3"><div class="table-responsive">

另一个使用 mask 的想法,您可以在其中具有透明度并可以在 Firefox 上工作

.table-responsive {面具:径向渐变(右侧圆 25px,透明 98%,#fff 100%)0 41px/27px 59px 重复-y,径向渐变(左侧圆 25px,透明 98%,#fff 100%)100% 41px/27px 59px 重复-y,线性梯度(#fff,#fff);掩码复合:排除;}

完整代码

var wrapper = document.querySelector("tbody");var myHTML = '';for (var i = 0; i <5; i++) {myHTML += '<tr>'+'<td>1</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>UKS127398SLA</td>'+'<td>2020-12-12</td>'+'<td>2020-12-12</td>'+'</tr>';}wrapper.innerHTML = myHTML;

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}身体td {背景:#fff;}.table 响应式 {-webkit-mask:径向渐变(右侧圆 25px,透明 98%,#fff 100%)0 41px/27px 59px 重复 Y,径向渐变(左侧圆 25px,透明 98%,#fff 100%)100% 41px/27px 59px 重复-y,线性渐变(#fff,#fff);-webkit-mask-composite:目的地输出;蒙版:径向渐变(右侧圆形 25px,透明 98%,#fff 100%)0 41px/27px 59px 重复 Y,径向渐变(左侧圆形 25px,透明 98%,#fff 100%)100% 41px/27px 59px 重复-y,线性渐变(#fff,#fff);掩码复合:排除;}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"><div class="page-wrapper"><div class="容器 pt-3"><div class="table-responsive">

要获得任何类型的半径,我们可以将径向渐变替换为 SVG,您可以在其中控制 rx/ry 来定义半径:

.table-responsive {面具:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="0" y="0" rx="10" ry="10" width="100" height="49" fill="black"/></svg>') 0 47px/27px59px 重复-y,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="0" rx="10" ry="10" width="77" height="49" fill="black"/></svg>') 100% 47px/27px 59px 重复-y,线性梯度(#fff,#fff) 中心/计算(100% - 27px*2) 100% 无重复;}

var wrapper = document.querySelector("tbody");var myHTML = '';for (var i = 0; i <5; i++) {myHTML += '<tr>'+'<td>1</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>UKS127398SLA</td>'+'<td>2020-12-12</td>'+'<td>2020-12-12</td>'+'</tr>';}wrapper.innerHTML = myHTML;

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}身体td {背景:#fff;}.table 响应式 {-webkit-掩码:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="0" y="0" rx="15" ry="15" width="100" height="49" fill="black"/></svg>') 0 47px/27px59px 重复-y,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="0" rx="15" ry="15" width="77" height="49" fill="black"/></svg>') 100% 47px/27px 59px 重复-y,线性梯度(#fff,#fff) 中心/计算(100% - 27px*2) 100% 无重复;面具:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="0" y="0" rx="15" ry="15" width="100" height="49" fill="black"/></svg>') 0 47px/27px59px 重复-y,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="0" rx="15" ry="15" width="77" height="49" fill="black"/></svg>') 100% 47px/27px 59px 重复-y,线性梯度(#fff,#fff) 中心/计算(100% - 27px*2) 100% 无重复;}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"><div class="page-wrapper"><div class="容器 pt-3"><div class="table-responsive">

最后一个想法(最受支持的一个)是考虑使用与上述 SVG 相同的技术进行叠加.这不会有透明度:

.container >分区{位置:相对;}.container >div::{之后内容:"";位置:绝对;顶部:47px;左:0;对:0;底部:0;背景:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-10" y="-10" rx="20" ry="20" width="100" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0 0,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="-10" rx="20" ry="20" width="87" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;背景尺寸:27px 59px;背景重复:重复-y;指针事件:无;}

完整代码

var wrapper = document.querySelector("tbody");var myHTML = '';for (var i = 0; i <5; i++) {myHTML += '<tr>'+'<td>1</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>UKS127398SLA</td>'+'<td>2020-12-12</td>'+'<td>2020-12-12</td>'+'</tr>';}wrapper.innerHTML = myHTML;

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}身体td {背景:#fff;}.container >分区{位置:相对;}.container >div::{之后内容:"";位置:绝对;顶部:47px;左:0;对:0;底部:0;背景:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-10" y="-10" rx="20" ry="20" width="100" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0 0,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="-10" rx="20" ry="20" width="87" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;背景尺寸:27px 59px;背景重复:重复-y;指针事件:无;}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"><div class="page-wrapper"><div class="容器 pt-3">

<div class="table-responsive">

更新

考虑使用最后一种方法除了水平滚动之外的垂直滚动:

var wrapper = document.querySelector("tbody");var myHTML = '';for (var i = 0; i <10; i++) {myHTML += '<tr>'+'<td>1</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>此区域用于文本描述</td>'+'<td>UKS127398SLA</td>'+'<td>2020-12-12</td>'+'<td>2020-12-12</td>'+'</tr>';}wrapper.innerHTML = myHTML;

.page-wrapper {背景颜色:#f1f2f5;}桌子 {空白:nowrap;边框折叠:分开;边框间距:0 10px;}.桌子 {位置:相对;边框折叠:分开;边框间距:0 10px;}.table td,.table th,.table tr,.table 标题,.table 正文 {边框:无;位置:相对;}.table thead th {边框:无;填充顶部:0;填充底部:0;}身体{位置:相对;}身体TR {边框半径:8px;边距底部:20px;位置:相对;}身体td {背景:#fff;}.container >分区{位置:相对;显示:网格;网格模板列:100% 1fr;最大高度:400px;溢出:自动;}.container >div >.table 响应式 {网格行:1;网格列:1/跨度 2;}.container >div::{之后内容:"";显示:块;网格行:1;网格列:1;z指数:2;边距顶部:47px;背景:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-10" y="-10" rx="20" ry="20" width="100" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0 0,url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><矩形 x="-50" y="-10" rx="20" ry="20" width="87" height="69" fill="透明" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;背景尺寸:27px 59px;背景重复:重复-y;指针事件:无;}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css"><div class="page-wrapper"><div class="容器 pt-3">

<div class="table-responsive">

I have a table which has a lot of data, so it has to be scrolled horizontally. I have designed the table seperating each row as each seperate cards but I unable get the border-radius on the left and right part of the table row properly. If i scroll towards the end of the right, then i can see the radius on right and same on left. When you are in middle you do not see any border radius.

PS: Applying radius to first and last td does not work when there is horizontal scroll. :(

Is there any trick to fix this so both the sides of border radius is visible all the time ? I don't have much idea on table since it does take limited attributes. Or maybe we will need javascript to get the desired output ?

I am looking it to be like this on the image below,

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}

tbody tr::after {
  content: '';
  width: 100%;
  position: absolute;
  left: 0;
  right: 0;
  background-color: #fff;
  height: 48px;
  z-index: 0;
  border-radius: 8px;
}

tbody td {
  z-index: 1;
}

<html lang="en" class="">

<head>
  <meta charset="UTF-8">
  <title>Demo</title>


  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

</head>

<body>
  <div class="page-wrapper">
    <div class="container pt-3">
      <div class="table-responsive">
        <table class="table no-wrap" style="
    position: relative;
">
          <thead>
            <tr>
              <th>SN</th>
              <th>Description 1</th>
              <th>Description 2</th>
              <th>Description 3</th>
              <th>Description 4</th>
              <th>Description 5</th>
              <th>Description 6</th>
              <th>Description 7</th>
              <th>Description 8</th>
              <th>Description 9</th>
              <th>Description 10</th>
              <th>Container</th>
              <th>Pickup Date</th>
              <th>Return Date</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
            <tr>
              <td>1</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>This Area is for text description</td>
              <td>UKS127398SLA</td>
              <td>2020-12-12</td>
              <td>2020-12-12</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>


</body>

</html>

解决方案

Here is a trick with position:sticky that seems to work fine only on Chrome (checking with firefox).

tbody tr::after,
tbody tr::before {
    content: '';
    display: block;
    position: sticky;
    right: 0; /* one will stick to the right */
    left: 0;  /* the other to the left */
    box-shadow:30px 0 0 6px #f1f2f5; /* a box-shadow to hide the outside */
    height: 48px;
    margin-left: -50px; /* big enough for the radius you will be using */
    z-index: 9;
    border-radius: 0 30px 30px 0; /* your radius */
}
tbody tr::before {
    margin-right: -50px;
    margin-left:0;    
    box-shadow:-30px 0 0 6px #f1f2f5;
    border-radius: 30px 0 0 30px;
}
thead tr::after,
thead tr::before  {
  content:"";
  display:block;
}
tbody td {
  background:#fff;
}

Full code:

var wrapper = document.querySelector("tbody");
var myHTML = '';

for (var i = 0; i < 5; i++) {
  myHTML += '<tr>' +
    '<td>1</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>UKS127398SLA</td>' +
    '<td>2020-12-12</td>' +
    '<td>2020-12-12</td>' +
    '</tr>';
}

wrapper.innerHTML = myHTML;

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}

tbody tr::after,
tbody tr::before {
    content: '';
    display: block;
    position: sticky;
    right: 0;    
    left: 0;
    box-shadow:30px 0 0 6px #f1f2f5;
    height: 48px;
    margin-left: -50px;
    z-index: 9;
    border-radius: 0 30px 30px 0;
}
tbody tr::before {
    margin-right: -50px;
    margin-left:0;    
    box-shadow:-30px 0 0 6px #f1f2f5;
    border-radius: 30px 0 0 30px;
}
thead tr::after,
thead tr::before  {
  content:"";
  display:block;
}

tbody td {
  background:#fff;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

  <div class="page-wrapper">
    <div class="container pt-3">
      <div class="table-responsive">
        <table class="table no-wrap" style="
    position: relative;
">
          <thead>
            <tr>
              <th>SN</th>
              <th>Description 1</th>
              <th>Description 2</th>
              <th>Description 3</th>
              <th>Description 4</th>
              <th>Description 5</th>
              <th>Description 6</th>
              <th>Description 7</th>
              <th>Description 8</th>
              <th>Description 9</th>
              <th>Description 10</th>
              <th>Container</th>
              <th>Pickup Date</th>
              <th>Return Date</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
      </div>
    </div>
  </div>

Another idea using mask where you can have transparency and will work on Firefox

.table-responsive {
    mask: 
      radial-gradient(circle 25px at right,transparent 98%,#fff 100%) 0    41px/27px 59px repeat-y,
      radial-gradient(circle 25px at left ,transparent 98%,#fff 100%) 100% 41px/27px 59px repeat-y,
      linear-gradient(#fff,#fff);
    mask-composite: exclude;
}

Full code

var wrapper = document.querySelector("tbody");
var myHTML = '';

for (var i = 0; i < 5; i++) {
  myHTML += '<tr>' +
    '<td>1</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>UKS127398SLA</td>' +
    '<td>2020-12-12</td>' +
    '<td>2020-12-12</td>' +
    '</tr>';
}

wrapper.innerHTML = myHTML;

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}

tbody td {
  background: #fff;
}

.table-responsive {
  -webkit-mask: radial-gradient(circle 25px at right, transparent 98%, #fff 100%) 0 41px/27px 59px repeat-y, radial-gradient(circle 25px at left, transparent 98%, #fff 100%) 100% 41px/27px 59px repeat-y, linear-gradient(#fff, #fff);
  -webkit-mask-composite: destination-out;
  mask: radial-gradient(circle 25px at right, transparent 98%, #fff 100%) 0 41px/27px 59px repeat-y, radial-gradient(circle 25px at left, transparent 98%, #fff 100%) 100% 41px/27px 59px repeat-y, linear-gradient(#fff, #fff);
  mask-composite: exclude;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

<div class="page-wrapper">
  <div class="container pt-3">
    <div class="table-responsive">
      <table class="table no-wrap" style="
    position: relative;
">
        <thead>
          <tr>
            <th>SN</th>
            <th>Description 1</th>
            <th>Description 2</th>
            <th>Description 3</th>
            <th>Description 4</th>
            <th>Description 5</th>
            <th>Description 6</th>
            <th>Description 7</th>
            <th>Description 8</th>
            <th>Description 9</th>
            <th>Description 10</th>
            <th>Container</th>
            <th>Pickup Date</th>
            <th>Return Date</th>
          </tr>
        </thead>
        <tbody>
        </tbody>
      </table>
    </div>
  </div>
</div>

To have any kind of radius we can replace the radial-gradient with an SVG where you can control the rx/ry to define the radius:

.table-responsive {
    mask: 
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="0"   y="0" rx="10" ry="10" width="100" height="49" fill="black"/></svg>') 0    47px/27px 59px repeat-y,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50" y="0" rx="10" ry="10" width="77"  height="49" fill="black"/></svg>') 100% 47px/27px 59px repeat-y,
      linear-gradient(#fff,#fff) center/calc(100% - 27px*2) 100% no-repeat;
}

var wrapper = document.querySelector("tbody");
var myHTML = '';

for (var i = 0; i < 5; i++) {
  myHTML += '<tr>' +
    '<td>1</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>UKS127398SLA</td>' +
    '<td>2020-12-12</td>' +
    '<td>2020-12-12</td>' +
    '</tr>';
}

wrapper.innerHTML = myHTML;

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}


tbody td {
  background:#fff;
}

.table-responsive {
     -webkit-mask:
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="0" y="0" rx="15" ry="15" width="100" height="49" fill="black"/></svg>') 0    47px/27px 59px repeat-y,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50" y="0" rx="15" ry="15" width="77" height="49" fill="black"/></svg>') 100% 47px/27px 59px repeat-y,
      linear-gradient(#fff,#fff) center/calc(100% - 27px*2) 100% no-repeat;
    mask: 
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="0"  y="0" rx="15" ry="15" width="100" height="49" fill="black"/></svg>') 0    47px/27px 59px repeat-y,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50" y="0" rx="15" ry="15" width="77" height="49" fill="black"/></svg>') 100% 47px/27px 59px repeat-y,
      linear-gradient(#fff,#fff) center/calc(100% - 27px*2) 100% no-repeat;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

  <div class="page-wrapper">
    <div class="container pt-3">
      <div class="table-responsive">
        <table class="table no-wrap" style="
    position: relative;
">
          <thead>
            <tr>
              <th>SN</th>
              <th>Description 1</th>
              <th>Description 2</th>
              <th>Description 3</th>
              <th>Description 4</th>
              <th>Description 5</th>
              <th>Description 6</th>
              <th>Description 7</th>
              <th>Description 8</th>
              <th>Description 9</th>
              <th>Description 10</th>
              <th>Container</th>
              <th>Pickup Date</th>
              <th>Return Date</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
      </div>
    </div>
  </div>

A final idea (the most supported one) is to consider an ovelay with the same technique of the SVG above. This won't have transparency:

.container > div{
  position:relative;
}
.container > div::after {
 content:"";
 position:absolute;
 top:47px;
 left:0;
 right:0;
 bottom:0;
 background: 
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-10"  y="-10" rx="20" ry="20" width="100" height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0    0,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50"  y="-10" rx="20" ry="20" width="87"  height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;
  background-size:27px 59px;
  background-repeat:repeat-y;
  pointer-events:none;
}

Full code

var wrapper = document.querySelector("tbody");
var myHTML = '';

for (var i = 0; i < 5; i++) {
  myHTML += '<tr>' +
    '<td>1</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>UKS127398SLA</td>' +
    '<td>2020-12-12</td>' +
    '<td>2020-12-12</td>' +
    '</tr>';
}

wrapper.innerHTML = myHTML;

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}


tbody td {
  background:#fff;
}

.container > div{
  position:relative;
}
.container > div::after {
 content:"";
 position:absolute;
 top:47px;
 left:0;
 right:0;
 bottom:0;
 background: 
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-10"  y="-10" rx="20" ry="20" width="100" height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0    0,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50" y="-10" rx="20" ry="20" width="87" height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;
  background-size:27px 59px;
  background-repeat:repeat-y;
  pointer-events:none;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

  <div class="page-wrapper">
    <div class="container pt-3">
    <div>
      <div class="table-responsive">
        <table class="table no-wrap" style="
    position: relative;
">
          <thead>
            <tr>
              <th>SN</th>
              <th>Description 1</th>
              <th>Description 2</th>
              <th>Description 3</th>
              <th>Description 4</th>
              <th>Description 5</th>
              <th>Description 6</th>
              <th>Description 7</th>
              <th>Description 8</th>
              <th>Description 9</th>
              <th>Description 10</th>
              <th>Container</th>
              <th>Pickup Date</th>
              <th>Return Date</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
      </div>
    </div>
    </div>
  </div>

UPDATE

Considering vertical scroll in addition to the horizontal one using the last method:

var wrapper = document.querySelector("tbody");
var myHTML = '';

for (var i = 0; i < 10; i++) {
  myHTML += '<tr>' +
    '<td>1</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>This Area is for text description</td>' +
    '<td>UKS127398SLA</td>' +
    '<td>2020-12-12</td>' +
    '<td>2020-12-12</td>' +
    '</tr>';
}

wrapper.innerHTML = myHTML;

.page-wrapper {
  background-color: #f1f2f5;
}

table {
  white-space: nowrap;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table {
  position: relative;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.table td,
.table th,
.table tr,
.table thead,
.table tbody {
  border: none;
  position: relative;
}

.table thead th {
  border: none;
  padding-top: 0;
  padding-bottom: 0;
}

tbody {
  position: relative;
}

tbody tr {
  border-radius: 8px;
  margin-bottom: 20px;
  position: relative;
}


tbody td {
  background:#fff;
}

.container > div{
  position:relative;
  display:grid;
  grid-template-columns:100% 1fr;
  max-height: 400px;
  overflow: auto;
}
.container > div > .table-responsive {
  grid-row:1;
  grid-column:1/span 2;
}
.container > div::after {
 content:"";
 display:block;
 grid-row:1;
 grid-column:1;    
 z-index: 2;
 margin-top: 47px;
 background: 
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-10"  y="-10" rx="20" ry="20" width="100" height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 0    0,
      url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 27 59"><rect x="-50" y="-10" rx="20" ry="20" width="87" height="69" fill="transparent" stroke="%23f1f2f5" stroke-width="20"/></svg>') 100% 0;
  background-size:27px 59px;
  background-repeat:repeat-y;
  pointer-events:none;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">

  <div class="page-wrapper">
    <div class="container pt-3">
    <div>
      <div class="table-responsive">
        <table class="table no-wrap" style="
    position: relative;
">
          <thead>
            <tr>
              <th>SN</th>
              <th>Description 1</th>
              <th>Description 2</th>
              <th>Description 3</th>
              <th>Description 4</th>
              <th>Description 5</th>
              <th>Description 6</th>
              <th>Description 7</th>
              <th>Description 8</th>
              <th>Description 9</th>
              <th>Description 10</th>
              <th>Container</th>
              <th>Pickup Date</th>
              <th>Return Date</th>
            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
      </div>
    </div>
    </div>
  </div>

这篇关于如何将边框半径应用于具有水平滚动的分隔表行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆