实现思路:使用outline属性,将定义的虚线outline,经过outline-offset往内偏移css
<div class="parent">
裁缝
</div>
.parent {
background: #324057;
width: 400px;
height: 200px;
line-height: 200px;
text-align: center;
color: white;
font-size: 2rem;
margin: 100px;
border-radius: 20px;
outline: 2px dashed currentColor;
outline-offset: -20px;
}
复制代码
outline的特色:bash
<div class="normal parent2">
外直里弯
</div>
.parent2 {
border-radius: 20px;
background: #ff9b00;
outline: 20px solid ;
box-shadow: 0 0 0 20px red;
}
复制代码
知识点:background:linear-gradient(direction, color...); spa
.parent3 {
background: linear-gradient(to right,cornflowerblue 50%,orange 0);
background-size: 30px 100%;
}
复制代码
思路:首先定义了通常是蓝,一半是橙;可是size肯定义了30px;也就是15px蓝,15px橙;再加上默认的repeat;那么就造成了重复条纹了。code
background: linear-gradient(45deg,orange 25%, cornflowerblue 25%, cornflowerblue 50%,orange 50%,orange 75%, cornflowerblue 75%,cornflowerblue 0);
background-size: 60px 60px;
复制代码
若是没有repeat,他长得样子就像下面这样,由4个条纹组成。 orm
接下来用到一个威猛的线性效果,repeat-linear-gradient;是的前面多了个repeat这个单词;cdn
.parent5 {
background: repeating-linear-gradient(45deg, orange , orange 15px ,cornflowerblue 15px, cornflowerblue 30px);
}
复制代码
上面代码的意思是:0-15px是橙,15-30px是蓝;你看到好像多余的颜色设置是为了清除渐变过渡效果。blog