js+css模拟自然界生态系统代码
代码语言:html
所属分类:其他
代码描述:模拟自然界生态系统网页
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>自然生态系统模拟器</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet">
<style>
:root {
--bg: #060e04;
--panel: #0c1a09;
--card: #132211;
--border: #1f3a18;
--fg: #d4e8c8;
--muted: #6a8a58;
--accent: #e5a828;
--accent2: #f0c050;
--prey: #4caf50;
--predator: #e8453c;
--water: #1e88e5;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
font-family: 'Outfit', sans-serif;
background: var(--bg);
color: var(--fg);
overflow: hidden;
height: 100vh;
display: flex;
}
#canvas-wrap {
flex: 1;
position: relative;
min-width: 0;
}
#eco-canvas {
display: block;
width: 100%;
height: 100%;
cursor: crosshair;
}
#overlay {
position: absolute;
top: 12px; left: 16px;
pointer-events: none;
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.badge {
background: rgba(12,26,9,0.85);
border: 1px solid var(--border);
border-radius: 8px;
padding: 5px 12px;
font-size: 13px;
font-weight: 600;
backdrop-filter: blur(6px);
display: flex;
align-items: center;
gap: 6px;
}
.badge .dot {
width: 8px; height: 8px;
border-radius: 50%;
display: inline-block;
}
#panel {
width: 340px;
min-width: 340px;
height: 100vh;
background: var(--panel);
border-left: 1px solid var(--border);
overflow-y: auto;
overflow-x: hidden;
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
}
#panel::-webkit-scrollbar { width: 5px; }
#panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.p-section {
padding: 16px 18px;
border-bottom: 1px solid var(--border);
}
.p-title {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1.5px;
color: var(--muted);
margin-bottom: 12px;
}
.slider-row {
margin-bottom: 10px;
}
.slider-label {
display: flex;
justify-content: space-between;
font-size: 12.5px;
margin-bottom: 4px;
color: var(--fg);
}
.slider-val {
color: var(--accent);
font-weight: 600;
min-width: 36px;
text-align: right;
}
input[type=range] {
-webkit-appearance: none;
width: 100%;
height: 4px;
background: var(--border);
border-radius: 2px;
outline: none;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 14px; height: 14px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
box-shadow: 0 0 6px rgba(229,168,40,0.4);
}
input[type=range]::-moz-range-thumb {
width: 14px; height: 14px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
border: none;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
padding: 7px 16px;
border-radius: 6px;
font-size: 12.5px;
font-weight: 600;
cursor: pointer;
border: 1px solid var(--border);
background: var(--card);
color: var(--fg);
transition: all 0.2s;
font-family: inherit;
display: flex;
align-items: center;
gap: 5px;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { border-color: #5a2020; color: #e88; }
.btn.danger:hover { background: #3a1515; }
#chart-canvas {
width: 100%;
height: 120px;
border-radius: 6px;
background: var(--card);
border: 1px solid var(--border);
}
.stat-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.stat-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 12px;
text-align: center;
}
.stat-card .val {
font-size: 22px;
font-weight: 800;
line-height: 1.1;
}
.stat-card .lbl {
font-size: 10px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 2px;
}
.gene-bar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
font-size: 12px;
}
.gene-bar .bar-wrap {
flex: 1;
height: 5px;
background: var(--border);
border-radius: 3px;
overflow: hidden;
}
.gene-bar .bar-fill {
height: 100%;
border-radius: 3px;
transition: width 0.3s;
}
#detail-panel { display: none; }
#detail-panel.active { display: block; }
.legend-item {
display: flex.........完整代码请登录后点击上方下载按钮下载查看















网友评论0