如何在CSS中制作逆透明圆

时间:2014-10-16 09:58:46

标签: css transparent

如何使用css使颜色背景上的部分透明? 这是这个背景的例子

enter image description here

我仍然没有尝试任何事情因为我不知道该怎么做所以请帮助我。 如果我把它作为div作为div并输入css:

.Xclass{ background: transparent; }

它仍然显示我的白色背景。

请帮帮我们。

2 个答案:

答案 0 :(得分:3)

<强> jsBin demo

  • 使用无背景放置overflow:hidden 正方形
  • 在该广场内 - 设置一个,其中box-shadow 展开半径高

&#13;
&#13;
#image{
  position:relative;
  margin:0 auto;
  background: url(http://i.imgur.com/gVcxX9C.png);
  height:500px;
  width:600px;
}
#box{
  position:absolute;
  left:300px;
  top:200px;
  width:200px;
  height:250px;
  overflow:hidden; /* to contain #circle's box-shadow */
}
#circle{
  position:relative;
  margin:30px auto;
  width: 150px;
  height:150px;
  box-shadow: 0 0 0 100px #fff; /* !!! */
  border-radius:50%;
}
&#13;
  <div id="image">
    <div id="box"><div id="circle"></div></div>
  </div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

尝试

.Xclass {
  opacity: 0.7;
}

.Xclass {
 background-color: rgba(15,15,15,0.7);
}