yd2333云顶电子游戏

网站代码精选。夯⊥敬牒霞

网站代码精选。夯⊥敬牒霞

想搭起一个能展示事情室、先容作品、适配手机并带有简朴交互的网站,,可以从下面这6段代码最先。。它们划分认真HTML骨架、基础样式、作品卡片、移动端结构、导航菜单和表单反响。。按顺序放入对应文件,,就能组成一个精练的静态展示站;;; ;;也可以先选用其中一段,,再逐步补齐其他功效。。

1. HTML骨架:安排导航、先容区和联系表单

先新建 index.html,,放入网站的主体结构。。导航链接划分跳转到带有对应 id 的区块,,访客还可以在联系表单中填写邮箱。。

<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>精练展示站</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header class="site-header">
    <a class="logo" href="#home">青禾事情室</a>
    <button class="menu-toggle" aria-expanded="false">菜单</button>
    <nav class="site-nav" aria-label="主导航">
      <a href="#about">关于</a>
      <a href="#works">作品</a>
      <a href="#contact">联系</a>
    </nav>
  </header>
  <main>
    <section class="hero" id="home">
      <p class="eyebrow">设计 · 创作 · 分享</p>
      <h1>让好点子,,清晰地被望见</h1>
      <p>用精练的方法先容团队、效劳与近期作品。。</p>
      <a class="cta" href="#works">浏览作品</a>
    </section>
    <section class="showcase-section" id="about">
      <h2>关于yd2333云顶电子游戏</h2>
      <p>青禾事情室专注于清晰、适用的数字创作。。</p>
    </section>
    <section class="showcase-section" id="works">
      <h2>精选作品</h2>
      <div class="card-grid">
        <article class="card"><h3>品牌视觉</h3><p>从标识到配色,,建设统一印象。。</p></article>
        <article class="card"><h3>网页设计</h3><p>突出重点,,让浏览路径更直接。。</p></article>
        <article class="card"><h3>运动策划</h3><p>把运动安排整理成易读的办法。。</p></article>
      </div>
    </section>
    <section class="showcase-section" id="contact">
      <h2>坚持联系</h2>
      <form id="contact-form">
        <label for="email">电子邮箱</label>
        <input id="email" name="email" type="email" required>
        <button type="submit">提交</button>
        <p id="form-message" aria-live="polite"></p>
      </form>
    </section>
  </main>
  <footer>? 青禾事情室</footer>
  <script src="script.js" defer></script>
</body>
</html>

2. 基础样式:统一字体、颜色与文字行宽

新建 style.css,,先设置全站通用规则,,再调解顶部导航和首屏。。用 max-width 限制段落行宽,,阻止宽屏上每行文字过长。。

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: #20302b;
  background: #f7f8f5;
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}
a { color: inherit; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px max(6%, calc((100% - 1120px) / 2));
  background: #fff;
}
.logo { font-weight: 700; text-decoration: none; }
.site-nav { display: flex; gap: 24px; }
.site-nav a { text-decoration: none; }
.menu-toggle { display: none; }
.hero {
  max-width: 1120px;
  margin: 0 auto;
  padding: 100px 24px;
}
.hero h1 { max-width: 720px; font-size: clamp(2.2rem, 6vw, 4.5rem); line-height: 1.15; }
.eyebrow { color: #47765e; font-weight: 700; }
.cta {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 20px;
  border-radius: 8px;
  color: #fff;
  background: #347354;
  text-decoration: none;
}

3. 作品卡片:让效劳先容一眼分层

卡片适合展示效劳、项目或文章摘要。。为每张卡片设置相同的内边距,,再用轻量边框区分条理,,不必堆叠重大装饰。。

.showcase-section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card {
  padding: 24px;
  border: 1px solid #e0e7e1;
  border-radius: 12px;
  background: #fff;
}
.card h3 { margin-top: 0; }
.card p { margin-bottom: 0; color: #58665f; }
form { max-width: 480px; }
label, input { display: block; width: 100%; }
input {
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px solid #b9c8bd;
  border-radius: 6px;
  font: inherit;
}
form button {
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: #347354;
  font: inherit;
  cursor: pointer;
}
footer { padding: 28px 6%; text-align: center; color: #58665f; }

4. 移动端结构:窄屏改为单列并睁开菜单

桌面端的三列卡片在手机上会显得拥挤。。用媒体盘问调解卡片列数、导航显示方法和首屏留白,,网站便能在小屏幕上坚持清晰。。

@media (max-width: 700px) {
  .site-header { position: relative; flex-wrap: wrap; }
  .menu-toggle { display: block; }
  .site-nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
  }
  .site-nav.is-open { display: flex; }
  .hero { padding: 68px 24px; }
  .card-grid { grid-template-columns: 1fr; }
}
@media (min-width: 701px) and (max-width: 960px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

这组断点将宽度不凌驾700px的手机结构设为单列,,701px至960px的中等屏幕显示两列,,其余宽屏则保存三列卡片。。

5. 导航交互:点击菜单睁开或收起选项

在项目目录中新建 script.js。。代码监听菜单按钮,,切换导航的显示类名,,并更新 aria-expanded,,利便辅助手艺读取按钮状态。。

const menuButton = document.querySelector(".menu-toggle");
const siteNav = document.querySelector(".site-nav");

menuButton.addEventListener("click", () => {
  const isOpen = siteNav.classList.toggle("is-open");
  menuButton.setAttribute("aria-expanded", String(isOpen));
});

siteNav.querySelectorAll("a").forEach((link) => {
  link.addEventListener("click", () => {
    siteNav.classList.remove("is-open");
    menuButton.setAttribute("aria-expanded", "false");
  });
});

点击“菜单”后,,手机上的导航选项会睁开;;; ;;选择“关于”“作品”或“联系”后,,菜单自动收起,,阻止导航一直占有屏幕。。

6. 表单反响。禾峤缓笙允久魅诽嵝

静态演示站尚未毗连后台时,,可以先用浏览器验证邮箱名堂,,并显示前端校验效果。。这种做法适合演示填写流程,,但不可取代真正的表单吸收效劳。。

const contactForm = document.querySelector("#contact-form");
const formMessage = document.querySelector("#form-message");

contactForm.addEventListener("submit", (event) => {
  event.preventDefault();

  if (!contactForm.checkValidity()) {
    contactForm.reportValidity();
    return;
  }

  formMessage.textContent = "邮箱名堂有用,,表单已完成前端校验。。";
  contactForm.reset();
});

组合使用时的检查顺序

把第1段生涯为 index.html,,第2至第4段依次放进 style.css,,再将第5、第6段放进 script.js。。翻开外地文件后,,按顺序检查导航跳转、三张作品卡片、窄屏单列结构、菜单睁开和邮箱名堂校验。。替换事情室名称、先容文案与卡片问题即可打造自己的展示站;;; ;;调解颜色时,,优先修改基础样式中的配景致与按钮色,,整体观感会更统一。。

ixbakqosorvyads748wyociubtjq
[责任编辑:程益中]

为您推荐

热门文章

精彩视频

凤凰资讯官方微信
凤凰资讯官方微信
关注更多资讯
【网站地图】【sitemap】