作者:袁立红第_593 | 来源:互联网 | 2023-02-11 12:48
我试图应用过渡属性,以便在悬停时图像更改时产生效果,但似乎不起作用.请看看并帮助我.
.ow-outer {
background-color: #fff;
width: 200px;
height: 200px;
border-radius: 50%;
border: 1px solid #fff;
text-align: center;
padding: 20px;
background-image: url(../images/team-canada-light.png);
background-size: 120px;
background-repeat: no-repeat;
background-position: center;
transition: all 0.3s ease-in-out;
}
.ow-outer:hover {
background-image: url(../images/team-canada.png);
}
LGSon..
8
转换background-image
不能跨浏览器工作,因此请使用伪元素
运用 opacity
.ow-outer {
position: relative;
background-color: #fff;
width: 200px;
height: 200px;
border-radius: 50%;
border: 1px solid #fff;
text-align: center;
padding: 20px;
background: url(http://placehold.it/200) no-repeat center;
background-size: 120px;
}
.ow-outer::before {
content: '';
position: absolute;
left: 0; top: 0; right:0; bottom: 0;
background: url(http://placehold.it/200/f00) no-repeat center;
background-size: inherit;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.ow-outer:hover::before {
opacity: 1;
}
运用 transform: scale
.ow-outer {
position: relative;
background-color: #fff;
width: 200px;
height: 200px;
border-radius: 50%;
border: 1px solid #fff;
text-align: center;
padding: 20px;
background: url(http://placehold.it/200) no-repeat center;
background-size: 120px;
}
.ow-outer::before {
content: '';
position: absolute;
left: 0; top: 0; right:0; bottom: 0;
background: url(http://placehold.it/200/f00) no-repeat center;
background-size: inherit;
transform: scale(0);
transition: transform 0.3s ease-in-out;
}
.ow-outer:hover::before {
transform: scale(1);
}
1> LGSon..:
转换background-image
不能跨浏览器工作,因此请使用伪元素
运用 opacity
.ow-outer {
position: relative;
background-color: #fff;
width: 200px;
height: 200px;
border-radius: 50%;
border: 1px solid #fff;
text-align: center;
padding: 20px;
background: url(http://placehold.it/200) no-repeat center;
background-size: 120px;
}
.ow-outer::before {
content: '';
position: absolute;
left: 0; top: 0; right:0; bottom: 0;
background: url(http://placehold.it/200/f00) no-repeat center;
background-size: inherit;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.ow-outer:hover::before {
opacity: 1;
}