كيفية إنشاء: نموذج تسجيل
- دليل الصفحة السابقة
- نموذج تسجيل الدخول الصفحة التالية
تعلم كيفية إنشاء نموذج تسجيل مرونقي باستخدام 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] { عرض: 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 { حافة: 1px مستقيمة #f1f1f1; هامش أسفل: 25px; } /* Set styles for all buttons */ button { background-color: #04AA6D; color: white; padding: 14px 20px; margin: 8px 0; border: none; سوقر: pointer; عرض: 100%; opacity: 0.9; } button:hover { opacity:1; } /* Set additional styles for the cancel button */ .cancelbtn { padding: 14px 20px; background-color: #f44336; } /* جعل زر الإلغاء والإنضمام عائمين وأضف نفس العرض */ .cancelbtn, .signupbtn { float: left; width: 50%; } /* إضافة حاشية داخلية إلى عنصر الحاوية */ .container { padding: 16px; } /* إزالة الفواصل --> .clearfix::after { محتوى: ""; تنظيف: كلاهما; عرض: table; } /* تعديل نمط زر الإلغاء والاشتراك في الشاشات الصغيرة جدًا */ @media screen and (max-width: 300px) { .cancelbtn, .signupbtn { عرض: 100%; } }
كيفية إنشاء نموذج تسجيل المودال
الخطوة الأولى - إضافة HTML:
استخدم عنصر <form> لمعالجة الإدخال. يمكنك الحصول على معلومات إضافية في دروسنا الخاصة بـ PHP.
ثم أضف عنصر تحكم إدخال لكل حقل (مع علامة التبويب المطابقة):
<!-- زر فتح المودال --> <button onclick="document.getElementById('id01').style.display='block'">تسجيل</button> <!-- المودال يحتوي على نموذج التسجيل --> <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] { عرض: 100%; padding: 15px; margin: 5px 0 22px 0; display: inline-block; border: none; background: #f1f1f1; } /* Add background color when the 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; سوقر: pointer; عرض: 100%; opacity: 0.9; } button:hover { opacity:1; } /* Set additional styles for the 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 the container element */ .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 */ لون الخلفية: #474e5d; هامش أعلى: 50px; } /* محتوى/مودال */ .modal-content { لون الخلفية: #fefefe; هامش: 5% auto 15% auto; /* هامش من الأعلى 5%، من الأسفل 15%، وركزًا في الوسط */ حافة: 1px مستقيمة #888; عرض: 80%; /* قد يكون أكثر أو أقل، اعتمادًا على حجم الشاشة */ } /* تعديل نمط الخط الأفقي */ hr { حافة: 1px مستقيمة #f1f1f1; هامش أسفل: 25px; } /* زر الإغلاق (x) */ .close { وضع: مطلق; يمين: 35px; أعلى: 15px; حجم النص: 40px; وزن النص: غليظ; لون: #f1f1f1; } .close:hover, .close:focus { لون: #f44336; سوقر: pointer; } /* تنظيف الزرافزادات */ .clearfix::after { محتوى: ""; تنظيف: كلاهما; عرض: table; } /* تعديل نمط زر الإلغاء والاشتراك في الشاشات الصغيرة جدًا */ @media screen and (max-width: 300px) { .cancelbtn, .signupbtn { عرض: 100%; } }
نصيحة:يمكنك أيضًا استخدام الأنواع التالية من كود JavaScript، من خلال النقر في أي مكان خارج محتوى المودال لإغلاق المودال (أيضًا وليس فقط من خلال استخدام زر "×" أو "إلغاء"):
<script> // 获取模态 var modal = document.getElementById('id01'); // 当用户单击模式之外的任何位置时,将其关闭 window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } </script>
تجربة شخصية
الصفحات ذات الصلةنموذج HTML
الصفحات ذات الصلةنموذج CSS
- دليل الصفحة السابقة
- نموذج تسجيل الدخول الصفحة التالية