San*_*ota 1 html css css-shapes
我正在尝试创建一个类似这样的形状。
在我的情况下,这是眉毛的形状。我用clip-path财产试过了。这样我在眉毛边界上有一个急转弯,我想避免。我认为必须有一种方法来实现这一目标。
我会很感激任何人帮助我解决我的问题。
谢谢你。
.avatar__eyebrow {
margin: 100px;
width: 52px;
height: 25px;
background: #000;
clip-path: polygon(57% 6%, 84% 0, 100% 14%, 97% 36%, 87% 51%, 55% 57%, 28% 72%, 0 100%, 25% 39%, 42% 23%);
}Run Code Online (Sandbox Code Playgroud)
<div class="avatar__eyebrow"></div>Run Code Online (Sandbox Code Playgroud)
使用多个背景的一种近似:
.eyebrow {
width: 200px;
height: 150px;
display: inline-block;
margin: 5px;
border-top-right-radius: 13%;
background:
radial-gradient(farthest-side at top left, transparent 98%, #fff 100%) 100% 19%/29px 16% no-repeat,
radial-gradient(116% 70% at bottom right, #fff 99%, transparent 100%),
radial-gradient(107% 100% at bottom right, #000 99%, transparent 100%);
}
/* extra */
.eyes {
width: 420px;
height: 130px;
margin-top: -146px;
position: relative;
background: radial-gradient(circle closest-side, #000 24%, transparent 26% 67%, #000 70% 80%, transparent 82%) 0/50% 100%;
}
.mouth {
width: 55px;
height: 10px;
background: #000;
border-radius: 20px;
position: relative;
margin-left: 190px;
transform: rotate(-14deg);
margin-top: 18px;
}Run Code Online (Sandbox Code Playgroud)
<div class="eyebrow" style="transform:scaleX(-1)"></div>
<div class="eyebrow"></div>
<div class="eyes"></div>
<div class="mouth"></div>Run Code Online (Sandbox Code Playgroud)
要理解拼图,请更改颜色并添加一些边框:
.box {
width:200px;
height:150px;
display:inline-block;
margin:5px;
border-top-right-radius:13%;
border:2px solid blue;
background:
radial-gradient(farthest-side at top left,green 98%,red 100%) 100% 19%/29px 16% no-repeat,
radial-gradient(116% 70% at bottom right,pink 99%,transparent 100%),
radial-gradient(107% 100% at bottom right,#000 99%,transparent 100%);
}
/* extra */
.eyes {
width: 420px;
height: 130px;
margin-top: -146px;
position: relative;
background: radial-gradient(circle closest-side, #000 24%, transparent 26% 67%, #000 70% 80%, transparent 82%) 0/50% 100%;
}
body {
background:yellow;
}Run Code Online (Sandbox Code Playgroud)
<div class="box" style="transform:scaleX(-1)"></div>
<div class="box"></div>
<div class="eyes"></div>Run Code Online (Sandbox Code Playgroud)
随着mask具有完全的透明度:
.eyebrow {
width:200px;
height:150px;
display:inline-block;
margin:5px;
border-top-right-radius:13%;
background: radial-gradient(107% 100% at bottom right,#000 99%,transparent 100%);
-webkit-mask:
radial-gradient(farthest-side at top left,transparent 98%,#fff 100%) 100% 19%/29px 16% no-repeat,
radial-gradient(116% 70% at bottom right,transparent 98%,#fff 100%);
-webkit-mask-composite: destination-out;
mask:
radial-gradient(farthest-side at top left,transparent 98%,#fff 100%) 100% 19%/29px 17% no-repeat,
radial-gradient(116% 68% at bottom right,transparent 98%,#fff 100%);
mask-composite: exclude;
}
/* extra */
.eyes {
width: 420px;
height: 130px;
margin-top: -146px;
position: relative;
background: radial-gradient(circle closest-side, #000 24%, transparent 26% 67%, #000 70% 80%, transparent 82%) 0/50% 100%;
}
.mouth {
width: 55px;
height: 10px;
background: #000;
border-radius: 20px;
position: relative;
margin-left: 190px;
transform: rotate(-14deg);
margin-top: 18px;
}
body {
background:linear-gradient(to right,pink,yellow);
}Run Code Online (Sandbox Code Playgroud)
<div class="eyebrow" style="transform:scaleX(-1)"></div>
<div class="eyebrow"></div>
<div class="eyes"></div>
<div class="mouth"></div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
352 次 |
| 最近记录: |