鼠标移入图片换为第二张图片,第二张图片从下向上滑动。鼠标移出,第二张图片向下滑动露出第一张图片。
我随手写了一个,题主可以看看实现思路
另外题主要学会用搜索引擎,这种搜索一大把
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.cansee {
width: 300px;
height: 400px;
margin: 0 auto;
border: 1px solid #000;
overflow: hidden;
}
#img1 {
width: 300px;
height: 400px;
background-color: red;
}
#img2 {
width: 300px;
height: 400px;
background-color: blue;
}
.box {
transition: all 1s ease-in-out;
}
.box:hover{
transform: translateY(-50%);
}
</style>
</head>
<body>
<div class="cansee">
<div class="box">
<div id="img1"></div>
<div id="img2"></div>
</div>
</div>
</body>
</html>
//html
<div class="box">
<img class="img1"/>
<img class="img2"/>
</div>
//css
.box{
width: 300px;
height: 800px;
}
.img1 {
width: 200px;
height: 200px;
background-color: red;
}
.img2 {
width: 200px;
height: 200px;
background-color: blue;
transition: all 1s ease-in-out;
}
.box:hover
.img2{
transform: translateY(-100%);
}
3 回答5.1k 阅读✓ 已解决
5 回答2k 阅读
3 回答1.4k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
2 回答1.9k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
仅使用css实现背景图片切换并滑动
逻辑:运用雪碧图把两张图片合并为一张图片,使用transition和background-position两个属性实现滑动切换.
demo:http://runjs.cn/detail/btbjrwwr