不幸的是,我在三角形部分遇到了麻烦。底层与顶层不匹配。我对三角形使用边框技术。底层应距顶层4px。
JSFiddle也位于底部。
<a class="btn" href="#"><span>Button text here</span></a>
scss:
.btn {
display: inline-block;
vertical-align: middle;
position: relative;
background: #EAC118;
padding: 0 30px;
line-height: 55px;
span {
display: block;
&::after {
content: '';
position: absolute;
top: 0;
right: -16px;
width: 0;
height: 0;
border-style: solid;
border-width: 27px 0 28px 16px;
border-color: transparent transparent transparent #EAC118;
}
}
&::before {
content: '';
position: absolute;
left: 4px;
bottom: -4px;
right: -6px;
height: 100%;
z-index: -1;
background: #ff0000;
}
&::after {
content: '';
position: absolute;
bottom: 0;
right: -22px;
width: 0;
height: 0;
z-index: -1;
border-style: solid;
border-width: 24px 0px 28px 16px;
border-color: transparent transparent transparent #ff0000;
}
}
这是怎么回事-我刚刚使span继承了相同的样式,并将其向右下方偏移-5px,然后使另一个箭头与外箭头对齐:
.btn,
.shadow {
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
position: relative;
background: #EAC118;
padding: 0 30px;
text-decoration: none;
line-height: 56px;
text-transform: uppercase;
font-family: Arial;
color: #ffffff;
}
.btn::after,
.shadow:after,
.shadow:before {
content: '';
position: absolute;
bottom: 0;
left: 100%;
width: 0;
height: 0;
z-index: 1;
border-style: solid;
border-width: 28px 0px 28px 15px;
border-color: transparent transparent transparent #EAC118;
}
.shadow {
position: absolute;
top: 5px;
left: 5px;
bottom: -5px;
right: -5px;
z-index: -1;
background: #ff0000;
}
.shadow::after {
border-color: white white white #ff0000;
left: calc(100% - 3px);
z-index: 1;
}
.shadow::before {
border-color: transparent transparent transparent #ff0000;
bottom: 5px;
z-index: 2;
}
.shadow > span {
display: block;
width: 5px;
height: 5px;
border-top: 5px solid #ffffff;
background: #ff0000;
position: absolute;
top: -5px;
right: -3px;
z-index: 3;
}
<a class="btn" href="#">
Button text here
<span class="shadow"><span></span></span>
</a>
使用背景图片的示例:
body {
background-size: cover;
margin: 0;
min-height: 100vh;
background: url(http://www.eelt.org.uk/img/eso1716a.jpg) left top no-repeat;
}
.btn {
margin:100px;;
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
position: relative;
background: #EAC118;
padding: 0 30px;
text-decoration: none;
line-height: 56px;
text-transform: uppercase;
font-family: Arial;
color: #ffffff;
}
.btn::before {
content: '';
display: block;
position: absolute;
height: 0px;
left: 5px;
right: 0;
bottom: -5px;
border-bottom: 5px solid #A5CAE5;
}
.btn::after {
content: '';
position: absolute;
bottom: -5px;
top: 0;
left: 100%;
width: 15px;
background: transparent url(https://i.stack.imgur.com/IFGSV.png) top left no-repeat;
background-size: 100% 100%;
}
<a class="btn" href="#">
Button text here
</a>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句