带有车把设计的按钮 Pure CSS 无图像
Button with Handlebar Design Pure CSS No Images
我想设计一个如下所示的按钮:
我知道这是一个局部问题,但我似乎无法让它看起来像那样没有图像
为了实现这样的效果,我同时使用了 :before
和 :after
伪元素。
然后您可以使用 CSS 转换属性的组合。类似带透视的旋转应该创建梯形,然后在另一个伪元素上使用边框来生成线条。
一个快速的模型演示是:
.demowrapper {
margin: 0 auto;
height: 500px;
background: lightgray;
width: 300px;
box-shadow: 0 0 20px 5px dimgray;
position: relative;
}
button {
position: absolute;
bottom: 0;
width: 100%;
left: 0;
height: 30px;
background: tomato;
display: inline-block;
border: 0;
cursor: pointer;
}
button:before {
content: "";
position: absolute;
height: 20px;
width: 50px;
background: inherit;
top: -18px;
left: 50%;
border-radius: 5px 5px 0 0;
transform: translateX(-50%) perspective(50px) rotateX(45deg);
}
button:after {
content: "";
position: absolute;
height: 2px;
width: 40px;
border-top: 2px solid black;
border-bottom: 2px solid black;
top: -8px;
left: 50%;
transform: translate(-50%);
}
button:hover{
background:yellow;
<div class="demowrapper">
<button>SELECT your Button</button>
</div>
我想设计一个如下所示的按钮:
我知道这是一个局部问题,但我似乎无法让它看起来像那样没有图像
为了实现这样的效果,我同时使用了 :before
和 :after
伪元素。
然后您可以使用 CSS 转换属性的组合。类似带透视的旋转应该创建梯形,然后在另一个伪元素上使用边框来生成线条。
一个快速的模型演示是:
.demowrapper {
margin: 0 auto;
height: 500px;
background: lightgray;
width: 300px;
box-shadow: 0 0 20px 5px dimgray;
position: relative;
}
button {
position: absolute;
bottom: 0;
width: 100%;
left: 0;
height: 30px;
background: tomato;
display: inline-block;
border: 0;
cursor: pointer;
}
button:before {
content: "";
position: absolute;
height: 20px;
width: 50px;
background: inherit;
top: -18px;
left: 50%;
border-radius: 5px 5px 0 0;
transform: translateX(-50%) perspective(50px) rotateX(45deg);
}
button:after {
content: "";
position: absolute;
height: 2px;
width: 40px;
border-top: 2px solid black;
border-bottom: 2px solid black;
top: -8px;
left: 50%;
transform: translate(-50%);
}
button:hover{
background:yellow;
<div class="demowrapper">
<button>SELECT your Button</button>
</div>