【发布时间】:2017-05-03 10:25:58
【问题描述】:
对于我正在开发的网站,我需要在div 中包含一些对角线形状的边框。这些是我需要重新创建的主要示例。
double diagonal top border, triangle shaped
现在一直在网上搜索如何实现这一点,我的第一个想法也是使用::before。但是,如果没有绝对定位,我无法让它工作,这会弄乱整个页面。
这是我尝试实现的代码:
.slider-container{
background-color: $blue;
width: 100%;
overflow: hidden;
position: relative;
.col-md-3{
img{
padding: 40px;
width: 100%;
max-width: 400px;
margin: auto;
}
}
&::before {
background: red;
bottom: 100%;
content: '';
display: block;
height: 100%;
position: absolute;
right: 0;
transform-origin: 100% 100%;
transform: rotate(-15deg);
width: 150%;
}
}
<section id="slider">
<div class="container-fluid">
<div class="row slider-container">
<div class="col-md-3">
<p>imgae 1</p>
</div>
<div class="col-md-3">
<p>imgae 2</p>
</div>
<div class="col-md-3">
<p>imgae 3</p>
</div>
<div class="col-md-3">
<p>imgae 4</p>
</div>
</div>
</div>
</section>
注意:它在这里不起作用,但这是我得到的结果result
【问题讨论】:
-
你能发布你尝试过的html和css吗?
-
尝试实现变换倾斜属性,例如
transform: skew(0deg,5deg); -
我会用我现在拥有的代码更新问题