【发布时间】:2015-06-21 01:52:37
【问题描述】:
我有一个以 svg 作为背景的按钮。 :hover 选择器工作正常,但是当我给它一个过渡时,按钮首先变小,然后跳回原始大小。如何阻止这种行为?
这是我的代码:
a {
width: 250px;
display: block;
color: rgba(0, 0, 0, .9);
text-decoration: none
}
.prod-ueber .cta-wrapper {
position: absolute;
left: 310px;
width: 100px;
top: 45px;
z-index: 5
}
.info-btn,
.korb-btn {
width: 50px;
height: 50px;
background-repeat: no-repeat;
background-size: 100%;
float: left;
transition: background .4s ease;
}
.info-btn {
background-image: url(http://imgh.us/info-btn.svg);
}
.korb-btn {
background-image: url(http://imgh.us/korb-btn.svg);
margin-left: 12px;
}
.info-btn:hover,
.info-btn:active,
.info-btn:focus {
background-image: url(http://imgh.us/info-btn_h.svg);
}
.korb-btn:hover,
.korb-btn:active,
.korb-btn:focus {
background-image: url(http://imgh.us/korb-btn_h.svg);
}
<a href="#">
<div class="prod-ueber">
<img src="http://dummyimage.com/" height="290" width="426" alt="Minze" class="img-responsive">
<h3 class="Artikelname">Malve</h3>
<small>Description</small>
<hr>
<h5 class="preis">€ 1,79</h5>
<div class="cta-wrapper">
<a href="#" class="info-btn"></a>
<a href="#" class="korb-btn"></a>
</div>
</div>
<!-- produkt -->
</a>
【问题讨论】:
-
感谢您的编辑,dawgs!
-
背景图片属性似乎不适用于过渡
-
这似乎是 Chrome 上过渡实现的一个错误,背景不包含在过渡属性中。检查这个答案:stackoverflow.com/questions/27760779/…
-
这是我使用
pseudo元素和background-imagejsfiddle.net/rk72xvdr 的解决方法
标签: css svg css-transitions