In Bootstrap 4 and 3 too, you can use the offset
to adjust the div in the center of the cointainer
.
Bootstrap 4
Notice that just put offset-2
in the first div and it worked. (see that with this I have 2 + 4 + 4 + 2, vc tb could do 3+3+3+3 col-3 offset-3
in the first div, just remember that at most can add up to 12 ok) Here is the official documentation on the offset, will help you understand the concept. https://getbootstrap.com/docs/4.0/layout/grid/#Offsetting-Columns
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
div[class^="col-"] {
height: 50px;
box-sizing: border-box;
border: 1px solid;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-4 offset-2">Col 1</div>
<div class="col-4">Col 2</div>
</div>
</div>
Bootstrap 3
In this example I did with two columns of 3 and 3 offset
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
/>
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
/>
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<style>
div[class^="col-"] {
height: 50px;
box-sizing: border-box;
border: 1px solid;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-3 col-xs-offset-3">.col-md-3 .col-md-offset-3</div>
<div class="col-xs-3">.col-md-3</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
Bootstrap 3 or 4? Edit your question and put your HTML code and CSS you used if possible.
– hugocsl
In version 4, thank you so much for the answer. helped me a lot =D
– user7069
Expensive in version 4 then it is even better pq Grid is in Flex. In the documentation there are some native classes of the framework that can also help you align things with Flex. Although for aso Col I prefer the same offset. Good luck with the project []s
– hugocsl