[英]Image with border-radius and :hover bug in Safari
When hovering over an image with border-radius, the style is set even when the cursor is outside the clipped image (inside the square containing the image). 将鼠标悬停在具有边框半径的图像上时,即使光标位于剪切的图像外部(包含图像的正方形内部),也将设置样式。
This happens in Safari; 这发生在Safari中; it works correctly in Firefox and Chrome.
它可以在Firefox和Chrome中正常运行。 Is there any way to fix it using CSS?
有什么办法可以使用CSS修复它吗?
.imagen { border-radius: 50%; } .imagen:hover { opacity: .5; }
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a0/Vado_l_ammazzo_e_torno-George_Hilton.jpg" class="imagen" />
The best cross-platform solution is probably to use the CSS url()
function with the background
property: 最好的跨平台解决方案可能是将CSS
url()
函数与background
属性一起使用:
#image { border-radius: 50%; height: 250px; width: 250px; background: url('https://upload.wikimedia.org/wikipedia/commons/a/a0/Vado_l_ammazzo_e_torno-George_Hilton.jpg') 0px 0px/contain; } #image:hover { opacity: .5; }
<div id='image'></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.