div+Css实现图片分解拆分碎片鼠标悬停合并一张整图效果代码
代码语言:html
所属分类:悬停
代码描述:div+Css实现图片分解拆分碎片鼠标悬停合并一张整图效果代码
代码标签: div Css 图片 分解 拆分 碎片 鼠标 悬停 合并 整图
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.grid-container {
display: grid;
grid-template-columns: repeat(10, 50px); /* 10 columns with 50px width each */
grid-template-rows: repeat(10, 50px); /* 10 rows with 50px height each */
gap: 50px; /* Gap between the grid items */
transition-duration: 2s;
}
.grid-container:hover {
gap: 0px; /* Gap between the grid items */
}
.grid-container .puzzle-piece {
//border-radius: 50%;
}
.grid-container .puzzle-piece:nth-child(6n) {
transform: rotate(360deg);
translate: 100px 0;
}
.grid-container .puzzle-piece:nth-child(6n + 1) {
transform: rotate(-90deg);
translate: 0px -100px;
}
.grid-container .puzzle-piece:nth-child(6n + 2) {
transform: rotate(180deg);
translate: 0px 100px;
}
.grid-container .puzzle-piece:nth-child(6n + 3) {
transform: rotate(270deg);
translate: -100px 0;
}
.grid-container .puzzle-piece:nth-child(6n + 4) {
transform: rotate(90deg);
translate: 100px 0px;
}
.grid-container .puzzle-piece:nth-child(6n + 5) {
transform: rotate(-180deg);
translate: -100px 0;
}
.grid-container:hover .puzzle-piece{
transform: rotate(0deg);
translate: 0 0;
border-radius: 0%;
}
.puzzle-piece {
width: 50px;
height: 50px;
background-image: url("//repo.bfw.wiki/bfwrepo/image/5d6539613d08b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_600,h_600,/quality,q_90");
background-size: 500px 500px; /* Adjust to the total grid size */
border: 0px solid #000;
transition-duration: 2s;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="puzzle-piece" style="background-position: 0px 0px;"></div>
<div class="puzzle-piece" style="background-position: -50px 0px;"></div>
<div class="puzzle-piece" style="background-position: -100px 0px;&.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0