我想在div的背景上绘制2条平行的对角线。
请在这里查看我的表格:
body {
background-image: url("http://i.imgur.com/TnPgXl4.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
padding: 40px;
}
#table {
width: 800px;
height: 300px;
background-color: transparent;
border: solid 1px white;
}
<div id="table"></div>
我想实现以下目标:
您可以使用旋转的伪元素获得2条对角线。这两条线是绝对定位的伪元素的顶部和底部边界:
body {
background-image: url("http://i.imgur.com/TnPgXl4.jpg");
background-size: cover;
background-repeat: no-repeat;
padding: 40px;
}
#table {
position: relative;
width: 800px; height: 300px;
background-color: transparent;
border: solid 1px white;
overflow: hidden;
}
#table:before {
content: '';
position: absolute;
right: 30%; bottom: 100%;
height: 20px; width: 100%;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform-origin: 100% 100%;
transform: rotate(-70deg);
}
<div id="table"></div>
这是这样的:
overflow:hidden;
div属性隐藏了请注意,您需要在transform和transform origin属性中添加供应商前缀以支持浏览器,并且可能不需要在background-size
属性上使用供应商前缀:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句