【发布时间】:2019-10-07 09:27:11
【问题描述】:
我想用纯 css 创建一个票形状(4 个角用圆圈裁剪),但是当我尝试为其添加边框时遇到了一些困难。我试图处理 box-shadow ,但我失败了。我正在尝试用两种风格制作它- 1. 我可以为整个形状设置 3px 边框,包括圆角 2. 我可以为整个形状设置一个 3px 的边框,但是是虚线样式
因为我对 box-shadow 不是很熟悉,所以我很难实现想要的风格。有人可以给我一些提示吗?太感谢了。
.ticket {
font-family: Arial;
font-size: 12px;
font-weight: bold;
position: relative !important;
background: #4a4a4a;
float: left;
padding: 35px 30px;
margin: 0 50px 50px 0;
}
.ticket:after {
content: "";
position: absolute !important;
z-index: 100;
top:0;
left: 0;
border-right: #fff 7px solid;
border-bottom: #fff 7px solid;
-moz-border-radius: 0 0 20px 0;
-webkit-border-radius: 0 0 20px 0;
border-radius: 0 0 20px 0;
background-color: white;
}
.ticket:before {
content: "";
position: absolute !important;
z-index: 100;
top: 0;
right: 0;
border-left: #fff 7px solid;
border-bottom: #fff 7px solid;
-moz-border-radius: 0 0 0 20px;
-webkit-border-radius: 0 0 0 20px;
border-radius: 0 0 0 20px;
}
.ticket a {
padding: 35px 35px 35px 20px;
text-decoration: none;
color: #fff;
white-space: nowrap;
}
.ticket a:hover {color: rgba(0,0,0,0.5);}
.ticket a:after {
content: "";
position: absolute !important;
z-index: 100;
bottom: 0;
left: 0;
border-right: #fff 7px solid;
border-top: #fff 7px solid;
-moz-border-radius: 0 20px 0 0;
-webkit-border-radius: 0 20px 0 0;
border-radius: 0 20px 0 0;
}
.ticket a:before {
content: "";
position: absolute !important;
z-index: 1000;
bottom: 0;
right: 0;
border-left: #fff 7px solid;
border-top: #fff 7px solid;
-moz-border-radius: 20px 0 0 0;
-webkit-border-radius: 20px 0 0 0;
border-radius: 20px 0 0 0;
}
<div class="ticket"><a href="#">Box A</a></div>
<div class="ticket"><a href="#">Box B</a></div>
<div class="ticket"><a href="#">Box C</a></div>
<div class="ticket"><a href="#">Box D</a></div>
【问题讨论】:
标签: html css border css-shapes box-shadow