html - 具有从阴影创建的边框的剪辑路径的边框半径

标签 html css svg

我有一个顶部 div 是动态的形状,我需要在这些 Angular 上添加边框半径。 shape 由两个共享线性渐变背景的 div 组成。边框是使用阴影生成的。

enter image description here

这是我的代码。

#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>

最佳答案

这是一个想法,我将考虑我在 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>

关于html - 具有从阴影创建的边框的剪辑路径的边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62589662/

相关文章:

javascript - 如何在这个js文件中使用Jquery的load函数?

html - 图像上的文本仅包含 css 和 html

javascript - 不要在 jQuery fadeOut() 之后重新定位剩余元素

javascript - Chrome 上的 Javascript 中的日期验证

javascript - 如何使用 D3 在 Angular 中使用 'this'?

svg - 在 Polymer 元素中设置 svg 的宽度和高度

firefox - Firefox 中除了 serif 和 sans-serif 之外还有 SVG 字体吗?

html - 如何强制表格单元格 <td> 内容换行?

html - CSS 将文本框与标签对齐

html - 在仅 chrome 的表单元素上使用 tab 键时页面滚动