我的顶部div是动态的,我需要在这些角上添加边框半径。形状由具有共同的线性渐变背景的两个div组成。并且边框是使用阴影生成的。
这是我的代码。
#parent {
width: max-content;
background:linear-gradient(to bottom left, transparent,rgba(255,255,255,0.75),transparent,rgba(255,255,255,0.75),transparent,rgba(255,255,255,0.75)) yellow;
}
#pool-container {
padding: 10px;
width: 200px;
margin: 0 5px 0 5px;
display: flex;
flex-direction: column;
position: relative;
filter: drop-shadow(0px -2px 0px black) drop-shadow(0px 2px 0px black) drop-shadow(-2px 0px 0px black) drop-shadow(2px 0px 0px black)
}
#side-step {
height: 80px;
width: 80px;
transition: 1s all;
}
#pool-container:hover #side-step {
margin-left: 120px;
}
#side-step,
#main-pool {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
#side-step::before,
#main-pool::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient( 120deg, rgba(248, 201, 129, 1) 0%, rgba(227, 76, 145, 1) 100%);
}
#main-pool {
width: 100%;
height: 150px;
}
<div id="pool-container">
<div id="side-step"></div>
<div id="main-pool"></div>
</div>
答案 0 :(得分:2)
在这里,我将考虑在this previous answer中使用的SVG过滤器。调整stdDeviation
值以控制半径:
#parent {
width: max-content;
background:linear-gradient(to bottom left, transparent,rgba(255,255,255,0.75),transparent,rgba(255,255,255,0.75),transparent,rgba(255,255,255,0.75)) yellow;
}
#pool-container {
padding: 10px;
width: 200px;
margin: 0 5px 0 5px;
display: flex;
flex-direction: column;
position: relative;
filter: url('#goo') drop-shadow(0px -2px 0px black) drop-shadow(0px 2px 0px black) drop-shadow(-2px 0px 0px black) drop-shadow(2px 0px 0px black)
}
#side-step {
height: 80px;
width: 80px;
transition: 1s all;
}
#pool-container:hover #side-step {
margin-left: 120px;
}
#side-step,
#main-pool {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
#side-step::before,
#main-pool::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient( 120deg, rgba(248, 201, 129, 1) 0%, rgba(227, 76, 145, 1) 100%);
}
#main-pool {
width: 100%;
height: 150px;
}
<div id="pool-container">
<div id="side-step"></div>
<div id="main-pool"></div>
</div>
<svg style="visibility: hidden; position: absolute;" width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="goo"><feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="goo" />
<feComposite in="SourceGraphic" in2="goo" operator="atop"/>
</filter>
</defs>
</svg>