【发布时间】:2020-09-13 18:34:19
【问题描述】:
:hover 效果仅在通过开发工具强制执行时有效,但在鼠标悬停时无效。 我尝试将浏览器从 mozilla、chrome 更改为 safari 但没有运气 为什么会这样? 我希望文本(玛丽...)在我悬停时立即出现在图像上...
这是我的代码,
.story {
width: 75%;
color: $color-black;
margin: 0 auto;
background-color: $color-white;
border-radius: 3px;
padding: 9rem 6rem;
padding-left: 9rem;
font-size: $default-font-size;
transform: skewX(-12deg);
& > * {
transform: skewX(12deg);
}
&__shape {
width: 17rem;
height: 17rem;
float: left;
-webkit-shape-outside: circle(50% at 50% 50%);
shape-outside: circle(50% at 50% 50%);
-webkit-clip-path: circle(50% at 50% 50%);
clip-path: circle(50% at 50% 50%);
transform: translateX(-3rem) skewX(12deg);
position: relative;
}
&__img {
height: 100%;
transform: translateX(-4rem) scale(1.4);
backface-visibility: hidden;
transition: all .5s;
}
&__caption {
text-transform: uppercase;
font-size: 1.7rem;
position: absolute;
top: 50%;
left: 55%;
transform: translate(-50%, 30%);
transition: all .4s;
color: $color-white;
opacity: 0;
&:hover {
opacity: 1;
transform: translate(-50%, -50%);
}
}
<div class="story">
<figure class="story__shape">
<img src="/img/nat-8.jpg" alt="Blonde" class="story__img">
<figcaption class="story__caption">mary smith</figcaption>
</figure>
</div>
【问题讨论】:
-
如果
&__caption的颜色为白色,则无论不透明度如何,您在悬停元素时可能都看不到它。 -
由于我在图像上超级强加文字,它是可见的......
标签: html css sass css-animations