我在Safari中遇到了一个过渡效果的问题,需要一些帮助。我的CSS悬停像它应该的那样交换了背景图像,但是悬停图像从它的位置向上和向左‘跳跃’(这是我不想发生的)。谢谢。
结构:
.sidebar .widget {
height: 276px;
width: 326px;
background:url('/wp-content/themes/a-theme/svg/polygon-image.svg') no-repeat center center;
background-size: 100%;
}
.sidebar .widget:hover {
background:url('/wp-content/themes/a-theme/svg/polygon-image-hover.svg') no-repeat center center;
background-size: 100%;
transition: 0.5s ease-in-out;
}<div class="sidebar">
<aside id="black-studio-tinymce-18" class="widget widget_black_studio_tinymce">
<div class="textwidget">
<h3 style="text-align: center;">Sample Text<br></h3>
</div>
</aside>
</div>
发布于 2017-08-12 22:58:06
避免浏览器的bug并进行清理:
.sidebar .widget {
height: 276px;
width: 326px;
background-repeat:no-repeat;
background-position: center center;
background-image:url(/wp-content/themes/a-theme/svg/polygon-image.svg);
background-size: 100%;
transition:background-image 0.5s ease-in-out;
}
.sidebar .widget:hover {
background-image:url(/wp-content/themes/a-theme/svg/polygon-image-hover.svg);
}发布于 2017-08-14 20:56:00
在您的帮助下,我修改了我的CSS以获得我需要的内容。我有一个多边形形状的背景图像和一个图形在它的中间。我保留了图形,转而使用CSS多边形作为形状,现在我的悬停效果在Firefox、Chrome和Safari中都有效。
请看我下面的CSS,再次感谢你的回复。
sidebar .widget {
background: url('/wp-content/uploads/2017/08/image.png') no-repeat center center;
background-color: rgba(255, 165, 0, 0.85);
background-size: 70%;
-webkit-clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
height: 276px;
width: 326px;
display: flex;
justify-content: center;
align-items: center;
}
.sidebar .widget:hover {
background: url('/wp-content/uploads/2017/08/image.png') no-repeat center center;
background-color: rgba(108, 218, 244, 0.8);
background-size: 80%;
-webkit-clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
height: 276px;
width: 326px;
transition: 0.5s ease-in-out;
}
https://stackoverflow.com/questions/45651510
复制相似问题