html - 如何使“剪辑路径”中的径向角看起来干净?
问题描述
我正在尝试制作一个形状不寻常的登录表单,但我正在努力解决border-radius
on a<div>
和clip-path
.
这是我在 a 上使用的 CSS <div>
:
background: red;
height: 80%;
-webkit-clip-path: polygon(100% 0, 0 0, 100% 100%);
clip-path: polygon(100% 0, 0 0, 100% 100%);
border-radius: 5em;
它目前看起来像这样:
如您所见,border-radius
左上角和右下角的 被切断。有没有办法让这个干净?
而不是切掉角落,我希望它们如下图所示。
解决方案
这篇文章很有帮助:dev.to/afif/css-shapes-with-rounded-corners-56h
你的例子:
.block {
display:inline-block;
width:460px;
height: 500px;
color:red;
margin:20px;
filter:url(#round);
backgroudn: red;
}
.block::before {
content:"";
display:block;
padding-top:100%;
background: red;
clip-path: polygon(100% 0, 0 0, 100% 100%);
}
<div class="block"></div>
<svg style="visibility: hidden; position: absolute;" width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="round">
<feGaussianBlur in="SourceGraphic" stdDeviation="5" 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>
如果要更改径向角的值,请更改stdDeviation
SVG 标签中的属性。
解决方案有一个问题是IOS显示不正确
我建议您将 SVG 用于类似的几何图形
推荐阅读
- javascript - (Angular) 如何将 html 中的#tag 定义转换为 Javascript?
- php - 如何在 PHP-OpenCloud/OpenStack 中批量删除
- excel - VBA 是否无法将整个段落替换为 Word 文档?
- powerapps - 循环遍历 Excel 数据源行
- angular - 在延迟加载的模块之间共享的 Angular 6 服务中注入 URL
- sql - Liquibase:列缓存
- c - 如何获取文件描述符的模式?
- java - 获取 Maven 编译错误无法执行目标 org.apache.maven.plugins
- python - 带有注意类的 Keras LSTM 输入维度设置
- ibm-cloud - 无法在管道作业中部署附加包