最近想实现带对角线的表头, 所以就使用css的
background
的linear-gradient
来画
<style>
.block {
width: 200px;
height: 200px;
}
</style>
<div class="block"></div>
使用线性渐变, 因为是正方形, 所以是45度角
.block {
background: linear-gradient(45deg, transparent 49.5%, #fff000 50.5%, #fff000 50.5%, transparent 50.5%);
}
https://codepen.io/klren0312/full/zYqPVXZ
<style>
.line {
padding: 20px 0;
position: relative;
background: linear-gradient(11deg, transparent 48.5%, #ff0000 49.5%, #ff0000 36.5%, transparent 51.5%);
}
.top,
.bottom{
position: absolute;
}
.top {
top: 0;
right: 20px;
}
.bottom {
bottom: 0;
left: 20px;
}
</style>
<table border>
<thead>
<tr>
<th>test1</th>
<th class="line" width="200px">
<div class="top">t1</div>
<div class="bottom">t2</div>
</th>
</tr>
</thead>
</table>
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。