To position the content of the column div you can use the responsive versions of justify-content-* class with d-flex
<div class="row">
<div class="col-md-4 d-flex justify-content-md-end justify-content-center">
Email
</div>
</div>
Just add the classes d-flex to display flex and justify-content-md-end to align at the end of the column for display md and upwards and justify-content-center to align to center for display xs and upwards.
Demo
Answer from Shiblu on Stack OverflowVideos
Bootstrap 5 (update 2021)
Since flexbox is still used the centering methods in Bootstrap 5 work the same way. Columns can be centered using offset, auto-margins or justify-content-center (flexbox).
Demo of the Bootstrap 5 Centering Methods
Bootstrap 4 (original answer)
There are multiple horizontal centering methods in Bootstrap 4...
text-centerfor centerdisplay:inlineelementsoffset-*ormx-autocan be used to center column (col-*)- or,
justify-content-centeron therowto center columns (col-*) mx-autofor centeringdisplay:blockelements insided-flex
mx-auto (auto x-axis margins) will center display:block or display:flex elements that have a defined width, (%, vw, px, etc..). Flexbox is used by default on grid columns, so there are also various flexbox centering methods.
Demo of the Bootstrap 4 Centering Methods
In your case, use mx-auto to center the col-3 and text-center to center it's content..
<div class="row">
<div class="col-3 mx-auto">
<div class="text-center">
center
</div>
</div>
</div>
https://codeply.com/go/GRUfnxl3Ol
or, using justify-content-center on flexbox elements (.row):
<div class="container">
<div class="row justify-content-center">
<div class="col-3 text-center">
center
</div>
</div>
</div>
Also see:
Vertical Align Center in Bootstrap
<div class="container">
<div class="row">
<div class="col d-flex justify-content-center">
CenterContent
</div>
</div>
</div>
Enable 'flex' for the column as we want & use justify-content-center
I'm not sure if you want horizontal or vertical center. The simplest way to horizontal center is to use mx-auto (auto-margins) on the inner w-75 divs...
https://www.codeply.com/go/orlziQBanZ
<div class="container">
<div class="row align-items-center">
<div class="col">
<div class="w-75 mx-auto" style="background-color: grey;">
<form>
<h3>Sign In</h3>
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary mb-2">Sign In</button>
</form>
</div>
</div>
<div class="col-1 mx-auto">
<h2 class="text-center">OR</h2>
</div>
<div class="col">
<div class="w-75 mx-auto" style="background-color: grey;">
<form>
<h3>Sign Up</h3>
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary mb-2">Sign Up</button>
</form>
</div>
</div>
</div>
</div>
The align-items-center on the row is for vertical centering.
To enable flexbox for the columns (and thus make the justify-content-center class work) you need to add the d-flex class to each column as shown in the code snippet below.
And if you only want to center text within a column like the "OR" text, then you only need the text-center class for that column.
Note: That "OR" text will squeeze out of the column when the column gets too narrow for the content to fit. So, you should use responsive column classes there and use responsive column classes for the other columns as well. Because as the screen gets smaller, you'd probably want them to stack.
Here's the code snippet (without responsive column classes i.e. based on your code):
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<section id="login">
<div class="container">
<div class="row">
<div class="col d-flex justify-content-center">
<div class="w-75" style="background-color: grey;">
<form>
<h3>Sign In</h3>
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary mb-2">Sign In</button>
</form>
</div>
</div>
<div class="col-2 text-center" style="background-color: grey;">
<h2>OR</h2>
</div>
<div class="col d-flex justify-content-center">
<div class="w-75" style="background-color: grey;">
<form>
<h3>Sign Up</h3>
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="input-group mb-2 mr-sm-2">
<input type="email" class="form-control" id="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary mb-2">Sign Up</button>
</form>
</div>
</div>
</div>
</div>
</section>
Use:
<!-- unsupported by HTML5 -->
<div class="col-xs-1" align="center">
instead of
<div class="col-xs-1 center-block">
You can also use bootstrap 3 css:
<!-- recommended method -->
<div class="col-xs-1 text-center">
Bootstrap 4 now has flex classes that will center the content:
<div class="d-flex justify-content-center">
<div>some content</div>
</div>
Note that by default it will be x-axis unless flex-direction is column
[Updated Apr 2022]: Tested and Included the 5.1 version of Bootstrap.
I know this question is old. And the question did not mention which version of Bootstrap he was using. So I'll assume the answer to this question is resolved.
If any of you (like me) stumbled upon this question and looking for answers using the current bootstrap 5.0 (2020) and 4.5 (2019) framework, then here's the solution.
Bootstrap 4.5, 5.0, and 5.1
Use d-flex justify-content-center on your column div. This will center everything inside that column.
<div class="row">
<div class="col-4 d-flex justify-content-center">
<!-- Image -->
</div>
</div>
If you want to align the text inside the col just use text-center
<div class="row">
<div class="col-4 text-center">
<!-- text only -->
</div>
</div>
If you have text and image inside the column, you need to use d-flex justify-content-center and text-center.
<div class="row">
<div class="col-4 d-flex justify-content-center text-center">
<!-- for image and text -->
</div>
</div>