js实现无限迷宫求解器代码
代码语言:html
所属分类:加载滚动
代码描述:js实现无限迷宫求解器代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Inter", sans-serif;
/* Use a subtle gradient background */
background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
overflow: hidden;
}
/* A centered “card” container for the maze */
#maze-container {
width: 90vw;
height: 90vh;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
#maze-grid {
width: 100%;
height: 100%;
display: grid;
gap: 2px;
/* a slightly larger gap between cells */
background-color: #ccc;
}
.maze-cell {
position: relative;
background-color: #fff;
transition: background-color 0.2s ease, transform 0.2s ease;
/* Ensure each cell stays square */
aspect-ratio: 1;
/* A subtle inner shadow for a modern “inset” look */
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}
.maze-cell::before {
content: "";
position: absolute;
background-color: #2c3e50;
transition: opacity 0.3s ease;
}
.maze-cell.wall-top::before {
top: 0;
left: 0;
right: 0;
height: 3px;
}
.maze-cell.wall-right::before {
top: 0;
right: 0;
bottom: 0;
width: 3px;
}
.maze-cell.wall-bottom::before {
bottom: 0;
left: 0;
right: 0;
height: 3px;
}
.maze-cell.wall-left::before {
top: 0;
left: 0;
bottom: 0;
width: 3px;
}
/* When a cell becomes a wall */
.maze-cell.wall {
background-color: #2c3e50;
}
/* Start and end cells get bold colors */
.maze-cell.start {
background-color: #4caf50 !important;
}
.maze-cell.e.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0