css - 如何用 CSS 制作鸡蛋形状
问题描述
尝试使用边界半径来定位我的 div 的左上角和左下角会获得接近效果,但无法获得如此剧烈的曲线。有一个优雅的解决方案吗?我已经稍微研究了剪辑路径,但不确定这是否是采取的方法。
解决方案
你可以这样做border-radius
:
.box {
width: 200px;
height: 200px;
position: relative;
overflow: hidden;
}
.box:before {
content: "";
position: absolute;
width: 120%;
height: 150%;
transform: rotate(-50deg) translate(45%, 15%);
background: grey;
border-radius: 35px;
}
<div class="box">
</div>
或者使用 SVG 作为背景:
.box {
width: 200px;
height: 200px;
position: relative;
background:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='grey'><path d='M32 0 C12 28 10 18 38 64 L64 64 L64 0 Z' /></svg>") center/100% 100% no-repeat;
}
<div class="box">
</div>
更新
如果你想使用下面的地图,你可以尝试这样的事情:
.box {
width: 200px;
height: 200px;
position: relative;
background:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='white'><path d='M32 0 C12 28 10 18 38 64 L0 64 L0 0 Z' /></svg>") center/100% 100% no-repeat,
url(https://picsum.photos/200/200?image=1069);
}
<div class="box">
</div>
推荐阅读
- css - Django,强制重新加载 css/js,并收集静态
- android - 未收到 SkuDetails 列表
- r - 有没有办法从 1 个 excel 文件在 ArcGIS 中执行批量插值?
- javascript - 如何从 Javascript 为傻瓜执行 Python 代码
- android - 下载管理器在 android 4 最多 6 中运行但不起作用?
- java - 使用 Spring Security 时获取当前登录的用户名
- javascript - 如何使用 reactJs 在本地保存大数据?
- reactjs - 如何在 ant 设计中制作垂直三等分页面的容器?
- php - Laravel 将多个产量添加到单个部分
- c# - 如何设置 SQL Server 数据库以允许多个用户通过 C# App 连接?