gpt4 book ai didi

CSS3 - 在 Sprite 图像的 'background-position' 之间淡入淡出

转载 作者:行者123 更新时间:2023-11-28 09:13:35 24 4
gpt4 key购买 nike

我想在 Sprite 图像的“背景位置”之间淡入淡出仅使用 CSS。我找到了很多 o 教程,但我没有找到像这样简单的东西:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3 - Fade between 'background-position' of a sprite image</title>
<style type="text/css">
div{
width: 120px;
height: 60px;

background-image: url('sprite.jpg');
background-repeat: no-repeat;
background-position: 0 0;

}
div:hover{
background-position: 0 -60px;
}
</style>
</head>
<body>
<div></div>
</html>

谢谢。

最佳答案

我找到了答案,无论如何谢谢。

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS3 - Fade between 'background-position' of a sprite image</title>
<style type="text/css">
#button{
float: left;
background-image: url('sprite.jpg');
background-position: 0 -60px;
background-repeat: no-repeat;

width: 120px;
height: 60px;
}
#button a{
background-image: url('sprite.jpg');
background-position: 0 0;
background-repeat: no-repeat;

width: 120px;
height: 60px;

display: block;
text-indent: -9999px;

transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
-webkit-transition: opacity 0.3s ease-in-out;
-o-transition: opacity 0.3s ease-in-out;
}
#button a:hover,
#button a:focus{
opacity: 0;
}


</style>
</head>
<body>
<div id="button"><a href="#"></a></div>
</html>

关于CSS3 - 在 Sprite 图像的 'background-position' 之间淡入淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15899865/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com