css - css剪辑路径圆
问题描述
假设我有一个具有以下样式的圆圈:
#edit-user-img {
clip-path: circle(100px at center);
background-color: rgba(0, 0, 0, 0.55);
color: white;
text-align: center;
z-index: 1;
top: 0;
display: block;
overflow: hidden;
width: 200px;
height: 200px;
position: absolute;
}
<a id="edit-user-img" href="#">
<i class="fa fa-pencil" aria-hidden="true"></i> Edit Picture
</a>
如何剪掉顶部的 145 像素,使其仅显示圆圈的底部 55 像素。我还希望文本出现在剪裁圆的底部。基本上我想在图片上创建一个花哨的编辑图像按钮。
解决方案
如果您想使用剪辑路径,我建议您使用矩形路径并border-radius
在元素上
div {
clip-path: polygon(0% 72.5%, 0 100%, 100% 100%, 100% 72.5%);
background-color: rgba(0, 0, 0, 0.55);
color: white;
text-align: center;
z-index: 1;
top: 0;
display: flex;
align-items: flex-end;
justify-content: center;
overflow: hidden;
width: 200px;
height: 200px;
border-radius: 50%;
}
span {
margin-bottom: 12%;
}
<div>
<span> Edit Picture</span>
</div>
推荐阅读
- ios - 在 info.plist 上放置一个资源字符串(来自 infoPlist.strings)
- wordpress - 如何为 Wordpress 设置 qTranslate 以自动为我提供德语,尽管我的网站语言是英语
- python - Python函数:f是什么意思?
- java - 如何使用 Spring Boot 设置 Spring JDBC 连接池?
- c# - 添加后无法使用ac#引用
- python - 在 python 中使用 selenium 创建一个用于网络抓取的循环
- syntax - 函数名和左括号之间的 Coffeescript 空格
- jquery - 下拉按钮不起作用也没有消失
- python-3.x - 如何用自定义类替换 h5py.AttributeManager?
- swift - 无法访问公共枚举 Swift 4.2