![](/img/trans.png)
[英]Element with border-radius inside element with border-radius is not consistent
[英]border-radius on a scrolling element
如果您的滚动div带有边框半径,则子级divs会黯淡或不遵守此边框半径。 例如,这是一个显示问题的小提琴:
http://jsfiddle.net/Thatguyhampton/E9dmr/2/
.scrollable {
overflow: auto;
overflow-y: overlay;
-webkit-overflow-scrolling: touch;
-webkit-transform: translate3d(0, 0, 0);
height: 400px;
width: 200px;
background-color: blue;
border-radius : .5em;
}
.content {
height: 500px;
width: 200px;
}
.content-top {
position :absolute;
top: 0;
height: 50px;
width : 200px;
background-color: red;
}
红色区域显示的是尖角,而不是父级的圆角。 有没有办法解决?
.scrollable {
overflow: auto;
overflow-y: overlay;
-webkit-overflow-scrolling: touch;
-webkit-transform: translate3d(0, 0, 0);
height: 400px;
width: 200px;
background-color: blue;
border-radius : .5em;
}
.content {
height: 400px;
width: 200px;
}
.content-top {
/*position :absolute;*/
top: 0;
height: 50px;
width : 200px;
background-color: red;
}
像DEMO这样更改此行:
.content-top {
position :absolute;
top: 0;
height: 50px;
width : 200px;
background-color: red;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
-moz-border-radius-topleft: 3px;
-moz-border-radius-topright: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
红色元素没有边框半径,而是悬停在可滚动的半径元素(蓝色元素)上。 边界半径无法裁剪! (仅边界半径)
解决此问题的方法:您可以将红色元素的border-radius添加到左上角。
.content-top {
border-top-left-radius : .5em;
}
.content-top {
/*position :absolute;*/
top: 0;
height: 50px;
width : 200px;
background-color: red;
}
在.content-top元素上注释掉“ position:absolute”可以解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.