如何制作垂直椭圆形 div?
How to make a vertical oval type of shape div?
我想创建一个如下图所示的椭圆形但失败了
另外,有什么方法可以在这个椭圆形 css 中插入图像吗?这是我的主要 objective.
#oval {
margin: 0px 0 10 02px;
background: black;
-moz-border-radius: 100px / 50px;
-webkit-border-radius: 100px / 70px;
border-radius: 50px / 50px;
border-top-left-radius: 150px;
border-top-right-radius: 150px;
border-bottom-left-radius: 150px;
border-bottom-right-radius: 150px;
width: 80px;
height: 100px;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="oval_parent">
<div id="oval"></div>
</div>
</body>
</html>
感谢@dgknca,
我尝试使用你的 clipreact 并添加 border-radius 完成了这项工作,
更新:问题,宽度和顶部高度看起来不错,但顶部曲线在我的要求图像中变平了,这个从顶部看太椭圆了,有什么帮助吗?
#oval {
margin: 0px 0 10 02px;
background: url("https://picsum.photos/536/354");
-moz-border-radius: 100px / 50px;
-webkit-border-radius: 100px / 70px;
border-radius: 50px;
clip-path: ellipse(50% 50% at 50% 50%);
width: 82.4px;
height: 100px;
}
<div id="oval"></div>
你可以把SVG当做mask,你可以很容易的得到这个形状。
.box {
width:300px;
display:inline-block;
background:url(https://picsum.photos/id/1074/800/800) center/cover;
-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 78' ><path d='M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z' /></svg>") 0 / 100% 100%;
mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 78' ><path d='M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z' /></svg>") 0 / 100% 100%;
}
.box::before {
content:"";
display:block;
padding-top:121%;
}
<div class="box"></div>
<div class="box" style="width:150px;"></div>
在我正在使用的 SVG 下方,如果您想在此处编辑它,这是一个很好的在线工具,您只需将路径附加到 url 中即可开始编辑:https://jxnblk.github.io/paths/?d=M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 64 78'
width='100' >
<path d='M0 39
C0 61 8 78 32 78
C56 78 64 61 64 39
C64 19 56 0 32 0
C8 0 0 19 0 39 Z' />
</svg>
我想创建一个如下图所示的椭圆形但失败了
另外,有什么方法可以在这个椭圆形 css 中插入图像吗?这是我的主要 objective.
#oval {
margin: 0px 0 10 02px;
background: black;
-moz-border-radius: 100px / 50px;
-webkit-border-radius: 100px / 70px;
border-radius: 50px / 50px;
border-top-left-radius: 150px;
border-top-right-radius: 150px;
border-bottom-left-radius: 150px;
border-bottom-right-radius: 150px;
width: 80px;
height: 100px;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="oval_parent">
<div id="oval"></div>
</div>
</body>
</html>
感谢@dgknca, 我尝试使用你的 clipreact 并添加 border-radius 完成了这项工作, 更新:问题,宽度和顶部高度看起来不错,但顶部曲线在我的要求图像中变平了,这个从顶部看太椭圆了,有什么帮助吗?
#oval {
margin: 0px 0 10 02px;
background: url("https://picsum.photos/536/354");
-moz-border-radius: 100px / 50px;
-webkit-border-radius: 100px / 70px;
border-radius: 50px;
clip-path: ellipse(50% 50% at 50% 50%);
width: 82.4px;
height: 100px;
}
<div id="oval"></div>
你可以把SVG当做mask,你可以很容易的得到这个形状。
.box {
width:300px;
display:inline-block;
background:url(https://picsum.photos/id/1074/800/800) center/cover;
-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 78' ><path d='M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z' /></svg>") 0 / 100% 100%;
mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 78' ><path d='M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z' /></svg>") 0 / 100% 100%;
}
.box::before {
content:"";
display:block;
padding-top:121%;
}
<div class="box"></div>
<div class="box" style="width:150px;"></div>
在我正在使用的 SVG 下方,如果您想在此处编辑它,这是一个很好的在线工具,您只需将路径附加到 url 中即可开始编辑:https://jxnblk.github.io/paths/?d=M0 39 C0 61 8 78 32 78 C56 78 64 61 64 39 C64 19 56 0 32 0 C8 0 0 19 0 39 Z
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 64 78'
width='100' >
<path d='M0 39
C0 61 8 78 32 78
C56 78 64 61 64 39
C64 19 56 0 32 0
C8 0 0 19 0 39 Z' />
</svg>