Boostrap Templates Login and Registration for Django
How TO - Login Form
Learn how to create a responsive login grade with CSS.
Click on the button to open the login class:
×
Try it Yourself »
How To Create a Login Form
Step i) Add HTML:
Add an image inside a container and add inputs (with a matching label) for each field. Wrap a <form> element around them to process the input. You tin can learn more near how to process input in our PHP tutorial.
Example
<class action="action_page.php" method="post">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" course="avatar">
</div>
<div course="container">
<characterization for="uname"><b>Username</b></characterization>
<input blazon="text" placeholder="Enter Username" name="uname" required>
<characterization for="psw"><b>Password</b></characterization>
<input blazon="password" placeholder="Enter Password" name="psw" required>
<button blazon="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</characterization>
</div>
<div class="container" style="background-color:#f1f1f1">
<button blazon="button" course="cancelbtn">Abolish</button>
<bridge class="psw">Forgot <a href="#">password?</a></bridge>
</div>
</form>
Step 2) Add CSS:
Example
/* Bordered form */
form {
border: 3px solid #f1f1f1;
}
/* Total-width inputs */
input[blazon=text], input[blazon=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
edge: 1px solid #ccc;
box-sizing: border-box;
}
/* Set a style for all buttons */
push {
groundwork-color: #04AA6D;
color: white;
padding: 14px 20px;
margin: 8px 0;
edge: none;
cursor: arrow;
width: 100%;
}
/* Add a hover effect for buttons */
button:hover {
opacity: 0.viii;
}
/* Extra style for the cancel button (red) */
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
/* Center the avatar image within this container */
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
/* Avatar image */
img.avatar {
width: 40%;
border-radius: l%;
}
/* Add padding to containers */
.container {
padding: 16px;
}
/* The "Forgot countersign" text */
span.psw {
float: right;
padding-pinnacle: 16px;
}
/* Alter styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: cake;
bladder: none;
}
.cancelbtn {
width: 100%;
}
}
Try information technology Yourself »
How To Create a Modal Login Form
Step ane) Add HTML:
Example
<!-- Button to open up the modal login form -->
<button onclick="document.getElementById('id01').style.display='cake'">Login</button>
<!-- The Modal -->
<div id="id01" form="modal">
<span onclick="document.getElementById('id01').style.brandish='none'"
class="close" title="Shut Modal">×</span>
<!-- Modal Content -->
<class course="modal-content animate" action="/action_page.php">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<input blazon="password" placeholder="Enter Password" proper name="psw" required>
<button blazon="submit">Login</push button>
<characterization>
<input blazon="checkbox" checked="checked" proper name="remember"> Think me
</label>
</div>
<div class="container" style="groundwork-color:#f1f1f1">
<push button blazon="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</class>
</div>
Step ii) Add CSS:
Example
/* The Modal (background) */
.modal {
display: none; /* Subconscious by default */
position: fixed; /* Stay in identify */
z-index: 1; /* Sit on tiptop */
left: 0;
pinnacle: 0;
width: 100%; /* Full width */
peak: 100%; /* Full meridian */
overflow: car; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-colour: rgba(0,0,0,0.iv); /* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5px machine; /* xv% from the top and centered */
edge: 1px solid #888;
width: fourscore%; /* Could be more or less, depending on screen size */
}
/* The Close Button */
.close {
/* Position it in the top right corner exterior of the modal */
position: absolute;
right: 25px;
top: 0;
colour: #000;
font-size: 35px;
font-weight: assuming;
}
/* Close button on hover */
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* Add together Zoom Animation */
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
@-webkit-keyframes animatezoom {
from {-webkit-transform: calibration(0)}
to {-webkit-transform: scale(1)}
}
@keyframes animatezoom {
from {transform: scale(0)}
to {transform: calibration(one)}
}
Tip: Yous can also use the post-obit javascript to close the modal past clicking outside of the modal content (and not just past using the "10" or "abolish" button to close it):
Case
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close information technology
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
Try information technology Yourself »
Tip: Go to our HTML Grade Tutorial to learn more about HTML Forms.
Tip: Go to our CSS Form Tutorial to learn more near how to style form elements.
Always heard near W3Schools Spaces? Here you can create your website from scratch or use a template, and host it for costless.
Get started for free ❯
* no credit card required
Boostrap Templates Login and Registration for Django
DOWNLOAD HERE
Source: https://www.w3schools.com/howto/howto_css_login_form.asp
Posted by: richardspenit1966.blogspot.com