我想得到一个自定义形状的图像,如下所示:
#oval-shape {
width: 200px;
height: 100px;
background: blue;
-moz-border-radius: 100px / 50px;
-webkit-border-radius: 100px / 50px;
border-radius: 100px / 50px;
}
<img id="oval-shape" src="http://d152j5tfobgaot.cloudfront.net/wp-content/uploads/2014/04/internship_yourstory.jpg">
如果这可能的话,有什么想法吗?
最佳答案
有一种方法可以用border
“伪造”这个形状:
body {
background: purple;
}
#oval-shape {
display:block;
margin: 20px auto;
width: 200px;
height: 200px;
background: none;
border-radius: 100%;
box-sizing: border-box;
border-bottom: 50px solid transparent;
}
<img src="http://d152j5tfobgaot.cloudfront.net/wp-content/uploads/2014/04/internship_yourstory.jpg" id="oval-shape">
关于html - 使用 CSS 自定义圆形图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37578582/