带角度形状的横幅
Banner with angled shapes
我正在尝试创建一个末端为三角形的横幅。
.wrapper {
padding: 50px;
font-size: 0px;
line-height: 0%;
width: 0px;
border-top: 20px solid gray;
border-bottom: 20px solid gray;
border-right: none;
}
<div class="wrapper">TEXT HERE</div>
试一试它有效
.wrapper {
font-family: arial;
font-size: 12px;
color: white;
background-color: black;
border: 1px solid white;
padding: 8px;
width: 100px;
text-align: center;
position: relative;
}
.wrapper:after {
content: '';
position: absolute;
border-top: 16px solid transparent;
border-bottom: 16px solid transparent;
border-right: 16px solid white;
z-index: 10;
top: 0px;
right: 0px;
}
<div class="wrapper">TEXT HERE</div>
只是帮助你解决这个问题,因为你已经尝试过了,但它没有像你预期的那样工作......所以基本的想法是我们可以使用 CSS 伪元素来创造这种效果..
.wrapper {
background: #C3C3C3;
padding: 20px;
font-size: 40px;
font-family: Arial;
text-align: center;
position: relative;
}
.wrapper:after {
content: "";
width: 0;
height: 0;
border-top: 42px solid transparent;
border-bottom: 42px solid transparent;
border-right: 40px solid white;
position: absolute;
right: 0;
top: 0;
}
<div class="wrapper">TEXT HERE</div>
在这里,我没有做任何花哨的事情,我们使用的是伪元素,即 DOM 中不存在的虚拟元素,但我们可以使用 CSS 插入它并定位它包装器右侧的伪元素。这将帮助您获得丝带般的末端。请注意,三角形的颜色是硬编码的,它不是透明的。
这里是fiddle。 https://jsfiddle.net/nileshmahaja/s5egaebr/
我在包装器中使用了 :after 选择器 div。
CSS
.wrapper {
padding: 0 50px;
font-size: 0px;
line-height: 0%;
width: 0px;
height:120px;
background:#ddd;
position:relative;
width:500px;
}
.wrapper:after {
content:'';
width: 0px;
height: 0px;
border-top: 60px solid transparent;
border-bottom: 60px solid transparent;
border-right: 60px solid #fff;
position:absolute;
right:0
}
我正在尝试创建一个末端为三角形的横幅。
.wrapper {
padding: 50px;
font-size: 0px;
line-height: 0%;
width: 0px;
border-top: 20px solid gray;
border-bottom: 20px solid gray;
border-right: none;
}
<div class="wrapper">TEXT HERE</div>
试一试它有效
.wrapper {
font-family: arial;
font-size: 12px;
color: white;
background-color: black;
border: 1px solid white;
padding: 8px;
width: 100px;
text-align: center;
position: relative;
}
.wrapper:after {
content: '';
position: absolute;
border-top: 16px solid transparent;
border-bottom: 16px solid transparent;
border-right: 16px solid white;
z-index: 10;
top: 0px;
right: 0px;
}
<div class="wrapper">TEXT HERE</div>
只是帮助你解决这个问题,因为你已经尝试过了,但它没有像你预期的那样工作......所以基本的想法是我们可以使用 CSS 伪元素来创造这种效果..
.wrapper {
background: #C3C3C3;
padding: 20px;
font-size: 40px;
font-family: Arial;
text-align: center;
position: relative;
}
.wrapper:after {
content: "";
width: 0;
height: 0;
border-top: 42px solid transparent;
border-bottom: 42px solid transparent;
border-right: 40px solid white;
position: absolute;
right: 0;
top: 0;
}
<div class="wrapper">TEXT HERE</div>
在这里,我没有做任何花哨的事情,我们使用的是伪元素,即 DOM 中不存在的虚拟元素,但我们可以使用 CSS 插入它并定位它包装器右侧的伪元素。这将帮助您获得丝带般的末端。请注意,三角形的颜色是硬编码的,它不是透明的。
这里是fiddle。 https://jsfiddle.net/nileshmahaja/s5egaebr/
我在包装器中使用了 :after 选择器 div。
CSS
.wrapper {
padding: 0 50px;
font-size: 0px;
line-height: 0%;
width: 0px;
height:120px;
background:#ddd;
position:relative;
width:500px;
}
.wrapper:after {
content:'';
width: 0px;
height: 0px;
border-top: 60px solid transparent;
border-bottom: 60px solid transparent;
border-right: 60px solid #fff;
position:absolute;
right:0
}