你只需要2个工具,无需安装复杂框架:
打开index.html,直接复制下方完整可运行的代码:
```html极简设计,响应式适配,无需复杂技术即可修改部署
立即联系这是一段关于个人/企业的介绍文字,你可以直接替换成自己的内容,保持简洁有力即可。
注重细节,打造舒适的用户体验
响应式架构,适配所有主流设备
纯原生代码,无冗余依赖
打开style.css,直接复制下方完整可运行的代码:
```css / 全局重置:消除浏览器默认样式差异 / { margin: 0; padding: 0; box-sizing: border-box; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; } / 通用容器:控制内容宽度,居中对齐,适配不同设备 / .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } / 导航栏样式 / .navbar { background-color: fff; box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: fixed; top: 0; left: 0; width: 100%; z-index: 999; } .navbar .container { display: flex; justify-content: space-between; align-items: center; height: 70px; } .logo { font-size: 24px; font-weight: bold; color: 333; text-decoration: none; } .nav-links { display: flex; list-style: none; gap: 30px; } .nav-links a { color: 555; text-decoration: none; font-size: 16px; transition: color 0.3s; } .nav-links a:hover { color: 2563eb; } / 移动端隐藏汉堡菜单默认显示 / .menu-toggle { display: none; background: none; border: none; font-size: 28px; color: 333; cursor: pointer; } / 主视觉区样式 / .hero { margin-top: 70px; min-height: calc(100vh - 70px); background: linear-gradient(135deg, 667eea 0%, 764ba2 100%); display: flex; align-items: center; text-align: center; color: fff; } .hero h1 { font-size: 48px; margin-bottom: 20px; } .hero p { font-size: 20px; margin-bottom: 40px; opacity: 0.9; } .btn-primary { display: inline-block; padding: 15px 40px; background-color: fff; color: 667eea; font-size: 18px; font-weight: bold; text-decoration: none; border-radius: 50px; transition: transform 0.3s, box-shadow 0.3s; } .btn-primary:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); } / 通用板块样式 / .section { padding: 80px 0; } .section h2 { text-align: center; font-size: 36px; margin-bottom: 20px; color: 333; } .section p { text-align: center; font-size: 18px; color: 666; margin-bottom: 50px; max-width: 700px; margin-left: auto; margin-right: auto; } / 关于区网格样式 / .about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; } .about-item { text-align: center; padding: 30px; border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.05); transition: transform 0.3s; } .about-item:hover { transform: translateY(-5px); } .about-item i { font-size: 50px; color: 2563eb; margin-bottom: 20px; } .about-item h3 { font-size: 22px; margin-bottom: 10px; color: 333; } .about-item p { font-size: 16px; margin-bottom: 0; } / 页脚样式 / .footer { background-color: 333; color: fff; padding: 30px 0; text-align: center; } .footer p { margin-bottom: 15px; opacity: 0.8; } .social-links { display: flex; justify-content: center; gap: 20px; } .social-links a { color: fff; font-size: 24px; transition: color 0.3s; } .social-links a:hover { color: 667eea; } / 响应式适配:屏幕宽度小于768px时(平板/手机)执行 / @media (max-width: 768px) { / 隐藏导航链接 / .nav-links { position: fixed; top: 70px; left: 0; width: 100%; background-color: fff; flex-direction: column; align-items: center; gap: 20px; padding: 20px 0; transform: translateY(-150%); transition: transform 0.3s; box-shadow: 0 5px 10px rgba(0,0,0,0.05); } / 显示导航链接的激活状态 / .nav-links.active { transform: translateY(0); } / 显示汉堡菜单按钮 / .menu-toggle { display: block; } / 主视觉区文字缩小 / .hero h1 { font-size: 32px; } .hero p { font-size: 16px; } } ```打开script.js,直接复制下方完整可运行的代码:
```javascript // 获取DOM元素 const menuToggle = document.getElementById('menuToggle'); const navLinks = document.getElementById('navLinks'); // 汉堡菜单点击事件 menuToggle.addEventListener('click', () => { navLinks.classList.toggle('active'); // 切换汉堡图标(可选,这里简化处理) const icon = menuToggle.querySelector('i'); icon.classList.toggle('ri-menu-line'); icon.classList.toggle('ri-close-line'); }); // 点击导航链接或空白处关闭汉堡菜单 document.addEventListener('click', (e) => { if (!menuToggle.contains(e.target) && !navLinks.contains(e.target)) { navLinks.classList.remove('active'); const icon = menuToggle.querySelector('i'); icon.classList.remove('ri-close-line'); icon.classList.add('ri-menu-line'); } }); // 导航链接点击事件:关闭汉堡菜单+平滑滚动 navLinks.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { navLinks.classList.remove('active'); const icon = menuToggle.querySelector('i'); icon.classList.remove('ri-close-line'); icon.classList.add('ri-menu-line'); }); }); ```推荐使用Vercel免费部署,无需购买服务器和域名(如需自定义域名可后续绑定):
易频IT社区是综合性互联网IT技术门户网站,专注分享网络技术、服务器运维、网络安全、编程开发、系统架构、云计算、大数据等行业干货,实时更新IT行业资讯、零基础教程、实战案例,为IT从业者、技术爱好者提供专业的学习交流平台。
Copyright © 2021-2026 易频IT社区. All Rights Reserved. 备案号:闽ICP备2023013482号 网站地图