gpt4 book ai didi

html - 如何给边框半径使元素看起来像这个图像?

转载 作者:行者123 更新时间:2023-11-28 05:17:13 25 4
gpt4 key购买 nike

我正在尝试使 .main-div 像这张图片一样

enter image description here

.main-div {
width: 100px;
height: 100px;
background-color: Red;
border-radius: 30px/20px;
}
<div class="main-div"></div>

我的 JSFiddle 是 here .

最佳答案

你可以使用一个伪元素来实现这个形状

body {
background: lightgray;
}

.main-div {
position: relative;
display: inline-block;
width: 110px;
height: 100px;
background-color: red;
border-radius: 30%/50%;
background: url(/image/CWoXa.png) center center no-repeat;
background-size: 110px 110px;
}

.main-div::after {
content: '';
position: absolute;
left: 5px;
top: -5px;
width: 100px;
height: 110px;
background: inherit;
background-size: inherit;
border-radius: 50%/30%;
}

.main-div+.main-div {
background: gray;
}
<div class="main-div"></div>
<div class="main-div"></div>

关于html - 如何给边框半径使元素看起来像这个图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43730742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com