Reputation: 145
I'm building a webpage and I need to create a registration and login form.
I wrote all the html/css code but I can't understand how to make fields to fit the form. I tried to modifie .modal-dialog and .modal-content CSS and by modifing .modal-content padding I can reduce the size of fields but a big white space remains all around them. How can I eliminate this white space?
.modal {}
.modal-content {
padding: 80px;
}
.modal-body input {
padding: 5px;
margin-bottom: 30px;
width: 100%;
box-sizing: border-box;
box-shadow: none;
outline: none;
border: none;
border-bottom: 2px solid #999;
}
.modal-body input[type="submit"] {
border-radius: 25px;
font-size: 20px;
height: 40px;
cursor: pointer;
background: rgb(255, 69, 0);
color: #fff;
margin-bottom: 0;
}
.modal-body input[type="submit"]:hover {
background: rgb(255, 127, 80);
color: #fff;
}
.modal-body form div {
position: relative;
}
.modal-body form div label {
position: absolute;
top: 3px;
pointer-events: none;
left: 0;
transition: .5s;
}
.modal-body input:focus~label,
.modal-body input:valid~label {
left: 0;
top: -16px;
color: rgb(169, 169, 169);
font-size: 12px;
font-weight: bold;
}
.modal-body input:focus,
.modal-body input:valid {
border-bottom: 2px solid rgb(169, 169, 169);
}
<!--Nav bar buttons-->
<form>
<!-- Button trigger modal -->
<button id="signupBtn" type="button" class="btn btn-primary" data-toggle="modal" data-target="#signupModalBtn">Registrati</button>
<button id="loginBtn" type="button" class="btn btn-primary" data-toggle="modal" data-target="#loginModalBtn">Log
In</button>
</form>
<!-- Modal SignUp-->
<div class="modal fade" id="signupModalBtn" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="contentinfo">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Registrati e inizia ad imparare!</h5>
<button id="signupCloseBtn" type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div>
<input type="text" name="Username" required="">
<label>Username</label>
</div>
<div>
<input type="text" name="First Name" required="">
<label>First Name</label>
</div>
<div>
<input type="text" name="Second Name" required="">
<label>Second Name</label>
</div>
<div>
<input type="email" name="Email" required="">
<label>Email </label>
</div>
<div>
<input type="password" name="Passowrd" required="">
<label>Password</label>
</div>
<div>
<input type="password" name="Re-Enter Password" required="">
<label>Re-Enter Password</label>
</div>
<input id="singupInternalBtn" type="submit" value="Registrati" name="Submit">
</form>
</div>
<div class="modal-footer">
<p id="signupBtnTextFooter">Hai già un account?Effettua il Log In!</p>
</div>
</div>
</div>
</div>
I'd like to create a registration/logIn form like Udemy ones (speaking about size),I'll add an img of what I got now!
Upvotes: 2
Views: 138
Reputation: 1609
Try giving below css, as modal-dialog need to have max-width, you need to set max-width for it like below,
body {
background: #000;
padding: 20px;
}
.modal-dialog {
max-width: 600px;
background: #FFF;
margin: auto;
}
.modal-content {
padding: 20px;
}
.modal {}
.modal-content {
padding: 80px;
}
.modal-body input {
padding: 5px;
margin-bottom: 30px;
width: 100%;
box-sizing: border-box;
box-shadow: none;
outline: none;
border: none;
border-bottom: 2px solid #999;
}
.modal-body input[type="submit"] {
border-radius: 25px;
font-size: 20px;
height: 40px;
cursor: pointer;
background: rgb(255, 69, 0);
color: #fff;
margin-bottom: 0;
}
.modal-body input[type="submit"]:hover {
background: rgb(255, 127, 80);
color: #fff;
}
.modal-body form div {
position: relative;
}
.modal-body form div label {
position: absolute;
top: 3px;
pointer-events: none;
left: 0;
transition: .5s;
}
.modal-body input:focus~label,
.modal-body input:valid~label {
left: 0;
top: -16px;
color: rgb(169, 169, 169);
font-size: 12px;
font-weight: bold;
}
.modal-body input:focus,
.modal-body input:valid {
border-bottom: 2px solid rgb(169, 169, 169);
}
body {
background: #000;
padding: 20px;
}
.modal-dialog {
max-width: 600px;
background: #FFF;
margin: auto;
}
.modal-content {
padding: 20px;
}
<!--Nav bar buttons-->
<form>
<!-- Button trigger modal -->
<button id="signupBtn" type="button" class="btn btn-primary" data-toggle="modal" data-target="#signupModalBtn">Registrati</button>
<button id="loginBtn" type="button" class="btn btn-primary" data-toggle="modal" data-target="#loginModalBtn">Log
In</button>
</form>
<!-- Modal SignUp-->
<div class="modal fade" id="signupModalBtn" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="contentinfo">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Registrati e inizia ad imparare!</h5>
<button id="signupCloseBtn" type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div>
<input type="text" name="Username" required="">
<label>Username</label>
</div>
<div>
<input type="text" name="First Name" required="">
<label>First Name</label>
</div>
<div>
<input type="text" name="Second Name" required="">
<label>Second Name</label>
</div>
<div>
<input type="email" name="Email" required="">
<label>Email </label>
</div>
<div>
<input type="password" name="Passowrd" required="">
<label>Password</label>
</div>
<div>
<input type="password" name="Re-Enter Password" required="">
<label>Re-Enter Password</label>
</div>
<input id="singupInternalBtn" type="submit" value="Registrati" name="Submit">
</form>
</div>
<div class="modal-footer">
<p id="signupBtnTextFooter">Hai già un account?Effettua il Log In!</p>
</div>
</div>
</div>
</div>
Upvotes: 2