用css3写的一个小demo——鼠标移动带扑克牌,扑克牌旋转铺开!图片和代码在下边
铺开的话有点小问题,感兴趣的可以自己改动一下
附上源码及图片
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>旋转扑克</title>
<style>
*{
margin: 0;
padding: 0;
}
div.box{
width: 120px;
height: 165px;
position: relative;
margin: 100px auto;
/* overflow: hidden; */
}
div.box div{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform-origin: 0 bottom;
transition: all .4s ease-in-out;
background: url('img/timg.jpg')no-repeat;
}
div.box:hover div:nth-child(1){
transform: rotate(15deg);
background: url('img/timg.jpg')no-repeat;
/* background-position: -133px 0px; */
}
div.box:hover div:nth-child(2){
transform: rotate(30deg);
background-position: -130px 0px;
}
div.box:hover div:nth-child(3){
transform: rotate(45deg);
background-position: -265px 0px;
}
div.box:hover div:nth-child(4){
transform: rotate(60deg);
background-position: -397px 0px;
}
div.box:hover div:nth-child(5){
transform: rotate(75deg);
background-position: -530px 0px;
}
div.box:hover div:nth-child(6){
transform: rotate(90deg);
background-position: 0px -172px;
}
div.box:hover div:nth-child(7){
transform: rotate(105deg);
background-position: -130px -172px;
}
div.box:hover div:nth-child(8){
transform: rotate(120deg);
background-position: -265px -172px;
}
div.box:hover div:nth-child(9){
transform: rotate(135deg);
background-position: -398px -172px;
}
div.box:hover div:nth-child(10){
transform: rotate(150deg);
background-position: -530px -174px;
/* background-position: 0 -348px; */
}
</style>
</head>
<body>
<div class="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
图片:
也可自行在网上下载自己想要的图片,百度搜索扑克牌即可
来源:CSDN
作者:Missing. You
链接:https://blog.csdn.net/weixin_42207353/article/details/103671582