body { font-family: Arial, sans-serif; line-height: 1.6; margin: 0; /* 使用 flexbox 布局实现 body 内元素的居中 */ display: flex; justify-content: center; align-items: center; padding-top: 80px; /* 增加顶部内边距避免内容被导航栏遮挡 */ min-height: calc(100vh - 80px); /* 补偿导航栏高度 */ } /* 导航栏样式 */ nav { position: fixed; top: 0; left: 0; right: 0; background-color: #f8f9fa; padding: 1rem 2rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); display: flex; justify-content: space-between; align-items: center; .nav-left .logo { font-weight: 700; font-size: 1.5rem; color: #2c3e50; text-decoration: none; } .nav-links { display: flex; gap: 2rem; list-style: none; margin: 0; padding: 0; } .nav-links a { text-decoration: none; color: #34495e; font-weight: 500; transition: color 0.3s ease; } .nav-links a:hover { color: #3498db; } .menu-toggle { display: none; cursor: pointer; padding: 10px 15px; font-size: 24px; } } main { /* 可选:添加一些内边距,让内容不紧贴容器边缘 */ padding: 20px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* 设置背景颜色为纯白色 */ background-color: #ffffff; color: #333; width: 40%; max-width: 1200px; } .scale-list .title { text-decoration: none; font-weight: 700; font-size: x-large; transition: color 0.3s ease; color: #34495e; } @media (max-width: 768px) { body { justify-content: baseline; align-items: baseline; } nav { .menu-toggle { display: block; } .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #ffffff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); flex-direction: column; padding: 10px; } .nav-links.active { display: flex; } } main { box-shadow: 0 0 10px rgba(0, 0, 0, 0); width: 95%; } } .scale { .scale-button { display: flex; input[type="radio"] { display: none; } label { flex-grow: 1; padding: 10px 0px; cursor: pointer; text-align: center; border: 3px solid #ffffff00; } input[type="radio"]:checked+label { border: 3px solid #909090; border-radius: 20px; } } input[type="submit"] { float: right; margin-top: 20px; background-color: #000000; color: rgb(255, 255, 255); padding: 15px 30px; border: none; border-radius: 4px; cursor: pointer; } }