css3实现0.5px边框、圆⾓渐变⾊边框+圆⾓渐变⾊背景
效果图
0.5px边框
0.5px边框,可以⽤伪元素实现,before、after都可以。移动端H5页⾯⽤的⽐较多。
圆⾓渐变⾊边框+圆⾓渐变⾊背景
实现外部圆⾓边框,内部圆⾓渐变⾊背景,是⽤⽗div + ⼦div实现的,其中⽗div和⼦div⽤不同的背景颜⾊,⽗div的padding⼤⼩,就是整体的边框⾼度。
如果内部div不需要圆⾓,可以参考这篇⽂章:
代码
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport"content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
<style>
.half-border{
position: relative;
width: 200px;
height: 100px;
line-height: 100px;
text-align: center;
}
.half-border::after{
content:"";
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
width: 200%;
height: 200%;
border-width: 1px;
border-style: solid;
border-color: red;
border-radius: 10px;
transform-origin: 0 0;
transform:scale(0.5);
/* z-index: 0; */
}
.border{
width: 200px;
height: 100px;
margin-left: 20px;
border: 1px solid red;
border-radius: 10px;
line-height: 100px;
text-align: center;
text-align: center;
}
.out-border-box{
width: 420px;
height: 50px;
padding:  6px;
margin-top: 20px;
box-sizing: border-box;
line-height: 100px;
border-radius:  24px;
background-image:linear-gradient(to left, rgba(0,199,119,0) 0%, rgba(0,199,119,0.2) 100%);
}
.inner-content-box{
width: 100%;
height: 100%;
color: #333333;
display: flex;
justify-content: flex-start;
align-items: center;
padding-left: 20px;
border-radius:  24px;
background: #fff;
background-image:linear-gradient(to left, rgba(2,220,136,0) 0%, rgba(168,255,223,0.15) 100%);
}
.half-border-bottom{
width: 200px;
height: 100px;
margin-top: 20px;
position: relative;
}
.half-border-bottom:before{
content:"";
position: absolute;
box-sizing: border-box;
width: 200%;
bottom: 0;
border-bottom: 1px solid red;
borderbox
-
webkit-transform-origin: 0 0;
-webkit-transform:scale(0.5, 0.5);
transform-origin: 0 0;
transform:scale(0.5, 0.5);
}
.border-bottom{
width: 200px;
height: 100px;
margin-top: 20px;
border-bottom: 1px solid red;
margin-left: 20px;
}
</style>
</head>
<body>
<div >
<div class="half-border">
0.5px边框
</div>
<div class="border">
1px边框
</div>
</div>
<div >
<div class="half-border-bottom">
0.5px边框
</div>
<div class="border-bottom">
1px边框
</div>
</div>
<div class="out-border-box">
<div class="inner-content-box">
渐变边框、渐变背景
</div>
</div> </body>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。