带有背景图片的毛刺行为div,Chrome中的边框半径

时间:2016-04-20 08:02:08

标签: html css css3 google-chrome

我在Chrome中遇到了一些小问题。

我尝试div border-radiusbackground-imageborderoverflow:hidden

在这个div中是某种必须被掩盖的叠加层。通过父div的overflow:hiddenborder-radius属性。

这样可行,但我在叠加div和父div的background-image之间看到了border的精细边框。

有解决方法吗?



body{
  background-color:black;
  }

.circle{
  background-image: url('http://www.augustaga.gov/images/pages/N1617/Black%20tupelo%20-%20photo%201.jpg');
  
  width: 250px;
  height: 250px;
  position: absolute;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  border: 2px solid white;
  overflow:hidden;
  
  
}
.overlay{
  top: 150px;
  position: absolute;
  height : 100px;
  width: 100%;
  background-color:white;
  text-align: center;
  
}

<div class="circle">
  <div class="overlay"> text</div>
</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

尝试将background-clip: padding-box;添加到.circle类

-webkit-background-clip: padding-box; 
-moz-background-clip:    padding; 
background-clip:         padding-box;

Source

答案 1 :(得分:0)

请试试这个:

你需要删除边框:2px纯白色; 形式.circle class。

所以它应该是:

.circle{
  background-image: url('http://www.augustaga.gov/images/pages/N1617/Black%20tupelo%20-%20photo%201.jpg');
  width: 250px;
  height: 250px;
  position: absolute;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  /* border: 2px solid white; */
  overflow: hidden;
}