Problem: I am trying to build a signup form and for some reason if there are any form groups inside of it, there is a slight overflow on the right side of the screen.
Already done: I have used Chromium dev tools and discovered that if I delete every .form-group then the overflow disappears. I also searched stack-overflow and Google to no avail.
Current Code: Here is my form (All of bootstrap is also included from the cdn)
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<div class="content">
<div class="row">
<div class="col-sm-12 col-md-3 col-lg-3 col-xl-4"></div>
<div class="col-sm-12 col-md-6 col-lg-6 col-xl-4">
<form class="">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter username">
</div>
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
</div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="confirmpassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmpassword" name="confirmpassword" placeholder="Confirm Password">
</div>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
And .content
is:
.content {
padding-left: 10px;
padding-right: 10px;
}
Expected results:
I'm sure you've guessed from the title but..
Expected: No overflow, and a happy life.
Actual: Mild overflow and plenty of sadness
Add overflow: hidden;
in your .content
css :
.content {
overflow: hidden;
padding-left: 10px;
padding-right: 10px;
}
Demo below :
.content {
overflow: hidden;
padding-left: 10px;
padding-right: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="content">
<div class="row">
<div class="col-sm-12 col-md-3 col-lg-3 col-xl-4"></div>
<div class="col-sm-12 col-md-6 col-lg-6 col-xl-4">
<form class="">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter username">
</div>
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
</div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="confirmpassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmpassword" name="confirmpassword" placeholder="Confirm Password">
</div>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
Alternatively, you can use bootstrap's built-in .container
class instead of your custom one (I even recommend this when using bootstrap, more infos here) and you don't even need to apply the overflow: hidden
hack :
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-3 col-lg-3 col-xl-4"></div>
<div class="col-sm-12 col-md-6 col-lg-6 col-xl-4">
<form class="">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter username">
</div>
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
</div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
<div class="form-group">
<label for="confirmpassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmpassword" name="confirmpassword" placeholder="Confirm Password">
</div>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>