当我正在尝试制作一个动画人物(悬停过渡)时,我发现<figure>
当我应用border-radius时,我的背景显示在边缘附近:50%,即使我的图像应该是占用所有可用空间.
有关说明问题的快速演示,请查看http://codepen.io/anon/pen/KwMMKz
HTML
<figure>
<img src="http://placehold.it/400x400" alt>
<figcaption>Demo</figcaption>
</figure>
Run Code Online (Sandbox Code Playgroud)
CSS
figure {
background-color: red;
width: 400px;
height: 400px;
border-radius: 50%;
overflow: hidden;
position: relative; /* For caption */
}
img {
border-radius: 50%; /* Forced on image for smooth transition */
width: 100%;
transition: opacity 1s ease-out;
}
figcaption {
position: absolute;
top: 100%;
left: 0;
width: 100%;
color: hotpink;
text-align: center;
transition: top 1s ease-out;
}
figure:hover img {
opacity: 0;
}
figure:hover figcaption {
top: …
Run Code Online (Sandbox Code Playgroud)