小编Sim*_* V.的帖子

由于包装元素上的背景颜色,边框半径为50%的锯齿状"边框";

当我正在尝试制作一个动画人物(悬停过渡)时,我发现<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)

css css3 background-color

6
推荐指数
1
解决办法
1206
查看次数

标签 统计

background-color ×1

css ×1

css3 ×1