css实现特殊的按钮形状-四个拐角空四边形
效果演示
<div class="box">
<div class="button">
按钮
</div>
</div>
<div class="box1">
哈哈
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<div class="box2">
哈哈
<span></span>
<span></span>
<span></span>
<span></span>
</div>
.box {
width: 100px;
margin: 0 auto;
margin-bottom: 20px;
}
.box .button {
width: 100px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
/* border: 1px solid #18324C; */
padding: 2px;
background: linear-gradient(to left, #fff, #fff) no-repeat left top,
linear-gradient(to left, #fff, #fff) no-repeat right top,
linear-gradient(to left, #fff, #fff) no-repeat left bottom,
linear-gradient(to left, #fff, #fff) no-repeat right bottom,
#9EE7FF;
background-size: 8px 8px, 8px 8px, 8px 8px, 8px 8px;
}
.box1{
position: relative;
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
background-color: #006DB7;
margin: 0 auto;
margin-bottom: 20px;
}
.box1 span{
display: block;
width: 8px;
height: 8px;
background-color: #fff;
}
.box1 span:nth-child(1){
position: absolute;
top: 0;
left: 0;
}
.box1 span:nth-child(2){
position: absolute;
top: 0;
right: 0;
}
.box1 span:nth-child(3){
position: absolute;
bottom: 0;
left: 0;
}
.box1 span:nth-child(4){
position: absolute;
bottom: 0;
right: 0;
}
/* -------------------------- */
.box2{
position: relative;
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
border: 1px solid #006DB7;
margin: 0 auto;
margin-bottom: 20px;
}
.box2 span{
display: block;
width: 8px;
height: 8px;
background-color: #fff;
}
.box2 span:nth-child(1){
position: absolute;
top: -1px;
left: -1px;
z-index: 2;
border-right: 1px solid #006DB7;
border-bottom: 1px solid #006DB7;
}
.box2 span:nth-child(2){
position: absolute;
top: -1px;
right: -1px;
z-index: 2;
border-left: 1px solid #006DB7;
border-bottom: 1px solid #006DB7;
}
.box2 span:nth-child(3){
position: absolute;
bottom: -1px;
left: -1px;
z-index: 2;
border-top: 1px solid #006DB7;
border-right: 1px solid #006DB7;
}
.box2 span:nth-child(4){
position: absolute;
bottom: -1px;
right: -1px;
z-index: 2;
border-top: 1px solid #006DB7;
border-left: 1px solid #006DB7;
}
使用css3属性或者自己裁切实现
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634206.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现