js+svg+css实现渐变方块交换小游戏代码
代码语言:html
所属分类:游戏
代码描述:js+svg+css实现渐变方块交换小游戏代码,连续点击2个方块交换位置完成整体渐变色。
代码标签: js svg css 渐变 方块 交换 小游戏 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
:root {
--x: 5;
--y: 5;
--x-percent: 500%;
--y-percent: 500%;
}
body {
color: #fff;
text-align: center;
font-family: sans-serif;
background-color: #1d1e22;
}
a {
color: #8db0ad;
}
#board {
display: grid;
grid-template-columns: repeat(var(--x), 1fr);
grid-template-rows: repeat(var(--y), 1fr);
width: 500px;
height: 500px;
margin: 0 auto;
}
#board > div {
position: relative;
display: flex;
align-items: center;
justify-content: center;
box-shadow: inset 0 25px 25px rgb(0 0 0 / 15%);
background: linear-gradient(-45deg, cyan 0%, white 100%);
/*background: url('https://plus.unsplash.com/premium_photo-1671429290897-5b29d44639c2?q=80&w=2072&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');*/
background-size: var(--x-percent) var(--y-percent);
}
#board > div::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.5;
background: linear-gradient(45deg, blue 0%, yellow 100%);
background-size: var(--x-percent) var(--y-percent);
background-position: inherit;
}
#board > div:nth-of-type(-n+25) {
background-position-y: 100%;
}
#board > div:nth-of-type(-n+20) {
background-position-y: 75%;
}
#board > div:nth-of-type(-n+15) {
background-position-y: 50%;
}
#board > div:nth-of-type(-n+10) {
background-position-y: 25%;
}
#board > div:nth-of-type(-n+5) {
background-position-y: 0%;
}
#board > div:nth-of-type(5n+1) {
background-position-x: 0%;
}
#board > div:nth-of-type(5n+2) {
background-position-x: 25%;
}
#board > div:nth-of-type(5n+3) {
background-position-x: 50%;
}
#board > div:nth-of-type(5n+4) {
background-position-x: 75%;
}
#board > div:nth-of-type(5n+5) {
background-position-x: 100%;
}
div.active, #board > div:not(:has(s.........完整代码请登录后点击上方下载按钮下载查看
网友评论0