html - 使用 CSS 自定义圆形图像

标签 html css css-shapes

我想得到一个自定义形状的图像,如下所示:

rounded image

#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">

DEMO

如果这可能的话,有什么想法吗?

最佳答案

有一种方法可以用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/

相关文章:

html - div 框不会使用属性显示 :inline-block; 排列

css - 用css制作一个奇形怪状的元素

javascript - 如何在 jquery 中使用它显示 div

javascript - 如何使可拖动和可调整大小的矩形在单击时出现并在释放时消失?

javascript - JQuery 单击添加类

CSS 性能

css - AngularJS 破坏了 Foundation 模态。解决方法?

html - 用CSS生成箭头线

html - css 生成箭头的框阴影

javascript - 通过单击弹出窗口外部来关闭弹出窗口