可能重复:
Rounding the sides of a big image contained in a small division not working in Chrome
我想做的是当用户将鼠标悬停在内部换行元素上时,会打开一个“保险库”。我遇到的问题是(至少在Chrome中)'门'没有被隐藏在内包装元素的边界半径区域之下。是否有任何CSS唯一的方法来纠正这一点,或者我将不得不看一些更复杂的东西?
HTML:
<div class="vault-wrap-1">
<div class="vault-wrap-2">
<div class="vault-door-1"></div>
<div class="vault-door-2"></div>
</div>
</div>
CSS:
div.vault-wrap-1 {
height:600px;
width:600px;
border-radius:9999px;
background:green;
margin:auto;
padding:30px;
}
div.vault-wrap-2 {
height:600px;
width:600px;
border-radius:9999px;
background:blue;
overflow:hidden;
}
div.vault-door-1, div.vault-door-2 {
height:600px;
width:300px;
background:red;
}
div.vault-door-1 {
float:left;
}
div.vault-door-2 {
float:right;
}
答案 0 :(得分:2)
在尝试对positioned
元素进行圆角处理时,这似乎仅在Webkit浏览器中存在问题。
如this answer所示,解决方案是向-webkit-mask-image
添加border-radius
元素:
div.vault-door-1, div.vault-door-2 {
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
}