CSS3 图像悬停在圆形 div 之外并带有过渡

标签 css transition

为什么图像在 hover 时会超出 overflow:hidden div,如何修复此错误?

例如:http://jsfiddle.net/b5EyS/

注意:chrome 有问题

screenshot

最佳答案

也通过向 img 添加 border-radius 解决了这个问题。不确定那是否是您想要的。请评论这是否重要!

a {
    width: 100px;
    height: 100px;
    background: #000;
    display: block;
    border: 2px solid #000;
    border-radius: 50%;
    overflow: hidden;
}
img {
    max-width: 100%;
   -webkit-transition: opacity 0.1s linear;
    -moz-transition: opacity 0.1s linear;
    -o-transition: opacity 0.1s linear;
    transition: opacity 0.1s linear;
    border-radius: 50%;
}
img:hover {
    opacity: 0.5;
}

关于CSS3 图像悬停在圆形 div 之外并带有过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23245116/

相关文章:

html - 在其 css 中具有过渡的元素的意外行为

javascript - 获取标题的高度并在滚动到标题之外时显示顶部导航

css - 如何防止字符在 CSS 'before' 'content' 中显示为表情符号?

jquery - 定位的 div 元素

javascript - 如何在D3中转换不同持续时间的异物组

android - 具有过渡效果的图像到视频转换

mysql - 使用表 2 中的数据更新表 1

html - 按特定顺序显示列中的元素

css - CSS 中 Assets 的 Symfony2 路径

html - 添加/删除/样式更改的 div 的 CSS3 转换/动画?