转载请注明出处:https://github.com/yisibl/blog/issues/2
刚刚在4.1.2的手机上又试了一下,发现不但要在div加border-radius,还要在img加border-radius,不然也会出现问题。
display: block;
width: 100%;
border-radius: 999px;
width: 200px;
height: 200px;
overflow: hidden;
border: 3px solid #000;
border-radius: 999px;
提供一个测试样本
Mozilla/5.0 (Linux; U; Android 4.2.1; zh-cn; HUAWEI G520-T10 Build/HuaweiG520-T10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 V1_AND_SQ_4.6.1_9_YYB_D QQ/4.6.1.1551
支持缩写, 需要加 background-clip: padding-box;
background-image: -webkit-gradient(linear, left top, left bottom, from(#背景色), to(#背景色)); /* Chrome, Safari 4+ /
background-image: -webkit-linear-gradient(top, #背景色, #背景色); / Chrome 10-25, iOS 5+, Safari 5.1+ /
background-image: -moz-linear-gradient(top, #背景色, #背景色); / Firefox 3.6-15 /
background-image: -o-linear-gradient(top, #背景色, #背景色); / Opera 11.10-12.00 /
background-image: linear-gradient(to bottom, #背景色, #背景色); / Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */
加上面的代码也可以把背景色溢出给消去,我之前都用上面的,楼主的方法比我的简单多了,受教了
@asd0102433 这个补充真是极好的,如果我没理解错,应该需要用 CSS mask 来解决。
顶,这个问题很早就遇到过,之前也找过解决方案,最后也是找到了 mask-image。
当时还记录了下:
jsFiddle