如何创建:菜单中的登录表单

学习如何创建其中包含登录表单的响应式导航菜单。

亲自试一试

如何在导航栏中添加登录表单

第一步 - 添加 HTML:

<div class="topnav">
  <a class="active" href="#home">Home</a>
  <a href="#about">About</a>
  <a href="#contact">Contact</a>
  <div class="login-container">
    <form action="/action_page.php">
      <input type="text" placeholder="Username" name="username">
      <input type="text" placeholder="Password" name="psw">
      <button type="submit">Login</button>
    </form>
  </div>
</div>

第二步 - 添加 CSS:

* {box-sizing: border-box;}
/* အသုံးပြု: အသုံးပြု */
.topnav {
  အကျယ်: hidden;
  နောက်ခံအရောင်: #e9e9e9;
}
/* အသုံးပြု: လက်ရှိ အသွင် */
.topnav a {
  ဝင်ကျတ်: left;
  ပြ: block;
  အရောင်: black;
  အစိတ်ထိုး: center;
  ပြင်းအား: 14 16ပမာဏ;
  အသား: none;
  အရွယ်: 17ပမာဏ;
}
/* မတွေ့: မတွေ့ မတွေ့ */
.topnav a:hover {
  နောက်ခံအရောင်: #ddd;
  အရောင်: black;
}
/* လက်ရှိ/လက်တွေ့ ချက်အသွင် */
.topnav a.active {
  နောက်ခံအရောင်: #2196F3;
  အရောင်: white;
}
/* အသုံးပြု: အရွယ်အစား အရွယ်အစား */
.topnav .login-container {
  ဝင်ကျတ်: right;
}
/* အသုံးပြု: လက်ရှိ အရွယ်အစား အရွယ်အစား */
.topnav input[type=text] {
  ပြင်းအား: 6ပမာဏ;
  အပြင်အား: 8ပမာဏ;
  အရွယ်: 17ပမာဏ;
  အဖက်: none;
  အကျယ်: 150ပမာဏ; /* လိုအပ်သော အချက်အလက်များ အရ ကျပ်လုပ် (အထိပ်တန်း နောက်ဆက်တွင် အဆိုးပါ) */
}
/* အရေးကြီးသော အသုံးပြု: အရေးကြီးသော အရွယ်ရှိ အရွယ်အစား အရွယ်အစား */
.topnav .login-container button {
  ဝင်ကျတ်: right;
  ပြင်းအား: 6ပမာဏ;
  အပြင်အား: 8ပမာဏ;
  အကျယ်ချဲ: 16ပမာဏ;
  နောက်ခံ: #ddd;
  အရွယ်: 17ပမာဏ;
  အဖက်: none;
  မတွေ့: pointer;
}
.topnav .login-container button:hover {
  နောက်ခံ: #ccc;
}
/* ထိန်းချိန်ထား - လုံးအချင်းအား ကျယ်ပြန့်တဲ့ ပုံစံများ တွင် လက်ရှိတွင် အဆင်းသတ်ချက်: 600ပမာဏ ထက် သိသိသာသာ */
@media screen and (max-width: 600px) {
  .topnav .login-container {
    ဝင်ကျတ်: none;
  }
  .topnav a, .topnav input[type=text], .topnav .login-container button {
    ဝင်ကျတ်: none;
    ပြ: block;
    အစိတ်ထိုး: ဆိုင်ချီ;
    အကျယ်: 100%;
    အစိတ်: 0;
    ပြင်းအား: 14ပမာဏ;
  }
  .topnav input[type=text] {
    border: 1px solid #ccc;
  }
}

亲自试一试