[英]CSS3 image with round corners and a very light oval shape
Hello I'm looking to build in CSS3 an image with round corners and a very light oval shape, like in this pic. 您好,我正在寻找在CSS3中构建一个圆角和非常浅的椭圆形图像,就像在这张照片中一样。
Not sure if it's possible and how. 不确定是否可能以及如何。 I know how to build a round image or an image with round corners, but this is a little different. 我知道如何建立圆形图像或圆角图像,但这有点不同。
UPDATE Here is what I've done 更新这是我所做的
.round{
background-color:red;
width:100px;
height:100px;
border-top-left-radius: 45px 40px;
border-top-right-radius: 45px 40px;
border-bottom-left-radius: 45px 40px;
border-bottom-right-radius: 45px 40px;
}
http://jsfiddle.net/7t1z3hxf/9/ http://jsfiddle.net/7t1z3hxf/9/
UPDATE2 Here are the schematics of what I'm trying to achieve UPDATE2以下是我想要实现的原理图
Thanks 谢谢
If perfect precision is what you want, I recommend mask-image
instead of border-radius
. 如果您想要完美的精度,我建议使用mask-image
而不是border-radius
。 It's much better suited for what you want. 它更适合你想要的东西。
To use your Illustrator-built(?) shape as a mask
in CSS, export it as SVG or PNG with transparent bg. 要在Illustrator中使用Illustrator构建的(?)形状作为mask
,请将其导出为带透明bg的SVG或PNG。
This will work in Chrome, Safari and Opera, but you need to use the prefixed -webkit-mask-image
. 这适用于Chrome,Safari和Opera,但您需要使用前缀-webkit-mask-image
。 The property is in progress of being merged with CSS mask-image
which only applied to SVG, hence the current need for a prefix. 该属性正在与仅应用于SVG的CSS mask-image
合并,因此当前需要前缀。 For other browsers, you may choose the lesser precise border-radius
. 对于其他浏览器,您可以选择较小的精确border-radius
。
.round{
-webkit-mask-image: url(yourshape.png);
-webkit-mask-size: contain;
-webkit-mask-position: center center;
/* ... border-radius as fallback */
}
Learn more about CSS Masking and browser support. 了解有关CSS Masking和浏览器支持的更多信息 。
If it's note exactly what you are looking for, I can mess with the border radii and round it or flatten it. 如果它准确地指出你正在寻找什么,我可以弄乱边界半径并将其环绕或压扁它。
#round { position: relative; width: 100px; height: 100px; margin: 20px 0; background: orange; border-radius: 48% / 25%; color: white; } #round:before { content: ''; position: absolute; top: 10%; bottom: 11%; right: -5%; left: -5%; background: inherit; border-radius: 21% / 68%; }
<div id="round"></div>
If I understood right you want something like this. 如果我理解得对,你想要这样的东西。
HTML: HTML:
<DIV CLASS="TEST"></DIV>
CSS: CSS:
.TEST{
width:230px;
height:240px;
background-image:url(IMAGE.JPG);
border-radius:100px;
background-position:center center;
background-size::230px 240px;
}
You may change the values to get the desired position. 您可以更改值以获得所需的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.