چگونه ایجاد می‌شود: فرم ثبت نام

آموزش ایجاد فرم ثبت نام پاسخگو با استفاده از CSS.

برای باز کردن فرم ثبت نام، روی دکمه کلیک کنید:

آموزش شخصی

چگونه فرم ثبت نام ایجاد می‌کنیم

قدم اول - اضافه کردن HTML:

از عنصر <form> برای پردازش ورودی استفاده کنید. می‌توانید اطلاعات بیشتری در آموزش PHP ما پیدا کنید.

سپس برای هر فیلد کنترل ورودی اضافه کنید (با برچسب‌های مطابقت‌دار):

<form action="action_page.php" style="border:1px solid #ccc">
  <div class="container">
    <h1>ثبت نام</h1>
    <p>لطفاً این فرم را پر کنید تا حساب کاربری خود را ایجاد کنید.</p>
    <hr>
    <label for="email"><b>ایمیل</b></label>
    <input type="text" placeholder="ایمیل را وارد کنید" name="email" required>
    <label for="psw"><b>رمز عبور</b></label>
    <input type="password" placeholder="ورود رمز عبور" name="psw" required>
    <label for="psw-repeat"><b>تکرار رمز عبور</b></label>
    <input type="password" placeholder="تکرار رمز عبور" name="psw-repeat" required>
    <label>
    <input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px">من را به خاطر بسپار
    </label>
    <p>با ایجاد یک حساب کاربری، شما موافقت می‌کنید که <a href="#" style="color:dodgerblue">شرایط و حریم خصوصی</a> ما را پذیرفته‌اید.</p>
    <div class="clearfix">
      <button type="button" class="cancelbtn">لغو</button>
      <button type="submit" class="signupbtn">ثبت نام</button>
    </div>
  </div>
</form>

第二步 - 添加 CSS:

* {box-sizing: border-box}
/* فیلدهای ورودی کامل عرض */
  input[type=text], input[type=password] {
  width: 100%;
  padding: 15px;
  margin: 5px 0 22px 0;
  display: inline-block;
  border: none;
  background: #f1f1f1;
}
input[type=text]:focus, input[type=password]:focus {
  background-color: #ddd;
  outline: none;
}
hr {
  border: 1px solid #f1f1f1;
  margin-bottom: 25px;
}
/* Set styles for all buttons */
button {
  background-color: #04AA6D;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  cursor: pointer;
  width: 100%;
  opacity: 0.9;
}
button:hover {
  opacity:1;
}
/* Set additional styles for cancel button */
.cancelbtn {
  padding: 14px 20px;
  background-color: #f44336;
}
/* برای دکمه‌های لغو و ثبت نام شناور کرده و عرض یکسان اضافه کنید */
.cancelbtn, .signupbtn {
  float: left;
  width: 50%;
}
/* به عنصر حاوی به‌عنوان محیط لبه داخلی اضافه کنید */
.container {
  padding: 16px;
}
/* پاک کردن شناور */
.clearfix::after {
  content: "";
  clear: both;
  display: table;
}
/* تغییر استایل دکمه‌های لغو و ثبت‌نام در صفحه‌های کوچک */
@media screen and (max-width: 300px) {
  .cancelbtn, .signupbtn {
    width: 100%;
  }
}

آموزش شخصی

چگونه فرم ثبت نام پنجره‌ای ایجاد می‌کنیم

قدم اول - اضافه کردن HTML:

از عنصر <form> برای پردازش ورودی استفاده کنید. می‌توانید اطلاعات بیشتری در آموزش PHP ما پیدا کنید.

سپس برای هر فیلد کنترل ورودی اضافه کنید (با برچسب‌های مطابقت‌دار):

<!-- Button to open the modal -->
<button onclick="document.getElementById('id01').style.display='block'">ثبت نام</button>
<!-- The Modal (contains the Sign Up form) -->
<div id="id01" class="modal">
  <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">زمان;</span>
  <form class="modal-content" action="/action_page.php">
    <div class="container">
      <h1>ثبت نام</h1>
      <p>لطفاً این فرم را پر کنید تا حساب کاربری خود را ایجاد کنید.</p>
      <hr>
      <label for="email"><b>ایمیل</b></label>
      <input type="text" placeholder="ایمیل را وارد کنید" name="email" required>
      <label for="psw"><b>رمز عبور</b></label>
      <input type="password" placeholder="ورود رمز عبور" name="psw" required>
      <label for="psw-repeat"><b>تکرار رمز عبور</b></label>
      <input type="password" placeholder="تکرار رمز عبور" name="psw-repeat" required>
      <label>
        <input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px"> به خاطر بسپار من
      </label>
      <p>با ایجاد یک حساب کاربری، شما موافقت می‌کنید که <a href="#" style="color:dodgerblue">شرایط و حریم خصوصی</a> ما را پذیرفته‌اید.</p>
      <div class="clearfix">
        <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">لغو</button>
        <button type="submit" class="signup">Register</button>
      </div>
    </div>
  </form>
</div>

第二步 - 添加 CSS:

* {box-sizing: border-box}
/* Full-width input fields */
  input[type=text], input[type=password] {
  width: 100%;
  padding: 15px;
  margin: 5px 0 22px 0;
  display: inline-block;
  border: none;
  background: #f1f1f1;
}
/* Add background color when input box gets focus */
input[type=text]:focus, input[type=password]:focus {
  background-color: #ddd;
  outline: none;
}
/* Set styles for all buttons */
button {
  background-color: #04AA6D;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  cursor: pointer;
  width: 100%;
  opacity: 0.9;
}
button:hover {
  opacity:1;
}
/* Set additional styles for cancel button */
.cancelbtn {
  padding: 14px 20px;
  background-color: #f44336;
}
/* Make cancel and register buttons float and set equal width */
.cancelbtn, .signupbtn {
  float: left;
  width: 50%;
}
/* Add padding to container elements */
.container {
  padding: 16px;
}
/* Model (background) */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: #474e5d;
  padding-top: 50px;
}
/* محتوای مدل/جعبه */
.modal-content {
  background-color: #fefefe;
  margin: 5% auto 15% auto; /* فاصله از بالا 5%,فاصله از پایین 15% و居انه */
  border: 1px solid #888;
  width: 80%; /* ممکن است بیشتر یا کمتر باشد، بستگی به اندازه صفحه نمایش دارد */
}
/* تنظیم استایل خط افقی */
hr {
  border: 1px solid #f1f1f1;
  margin-bottom: 25px;
}
/* دکمه بستن (x) */
.close {
  position: absolute;
  right: 35px;
  top: 15px;
  font-size: 40px;
  font-weight: bold;
  color: #f1f1f1;
}
.close:hover,
.close:focus {
  color: #f44336;
  cursor: pointer;
}
/* پاک کردن شناورها */
.clearfix::after {
  content: "";
  clear: both;
  display: table;
}
/* تغییر استایل دکمه‌های لغو و ثبت‌نام در صفحه‌های کوچک */
@media screen and (max-width: 300px) {
  .cancelbtn, .signupbtn {
    width: 100%;
  }
}

توجه:شما همچنین می‌توانید از کد JavaScript زیر استفاده کنید تا با کلیک روی هر بخشی از محتوای مدل‌ها، مدل‌ها را ببندید (و نه تنها با استفاده از دکمه "×" یا "لغو"):

<script>
// دریافت مدل
var modal = document.getElementById('id01');
// زمانی که کاربر روی هر بخشی از مدل خارج از آن کلیک کند، آن را ببند
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
</script>

آموزش شخصی

آموزش شخصی

صفحات مرتبطفرم HTML

صفحات مرتبطفرم CSS