Reputation: 195
I want to do this style in an archive .html
I want to be able to write inside white text area.
I'm starting with this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
</head>
<body>
<div class="container">
<h1>Hello</h1>
<p>hi.</p>
<div class="row">
<div class="col-sm-6" style="background-color:yellow;">
hola
</div>
<div class="col-sm-3" style="background-color:pink;">
adios
</div>
</div>
</div>
</body>
</html>
Produce:
So, how can I get this?(separation between the row)
Upvotes: 3
Views: 9605
Reputation: 3848
I have added the code according to the latest bootstrap v4. There are slight changes in the syntax while giving offset. And also the breakpoints have changed. xs in bootstrap v3 is equal to sm in bootstrap 4, md equal to lg and likewise.Hope it will be helpful.
Refer for more : https://getbootstrap.com/docs/4.0/layout/grid/
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Hello</h1>
<p>hi.</p>
<div class="row">
<div class="col-sm-6" style="background-color:yellow;">
hola
</div>
<div class="col-sm-3 offset-sm-3" style="background-color:pink;">
adios
</div>
</div>
</div>
</body>
</html>
Upvotes: 1
Reputation: 853
Actually bootstrap does have a "gutter space" between columns. What you need is an element inside your col-div-* for this gutter to be visible. You could also use an offset as others have suggested, but you have to think about what you really want to to accomplish.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
</head>
<body>
<div class="container">
<h1>Hello</h1>
<p>hi.</p>
<div class="row">
<div class="col-xs-9" >
<div style="background-color:yellow; padding: 10px;">hola</div>
</div>
<div class="col-xs-3">
<div style="background-color:pink;">adios</div>
</div>
</div>
</div>
</body>
</html>
Upvotes: 1
Reputation: 272816
Simply consider offset like below. You have a total of 9 columns of the grid used (6 + 3) so you can add an offset up to 3 to have a total of 12.
(i replaced sm
with xs
to see the result in the reduced snippet)
.row {
margin-bottom:10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<h1>Hello</h1>
<p>hi.</p>
<div class="row">
<div class="col-xs-6" style="background-color:yellow;">
hola
</div>
<div class="col-xs-3 col-xs-offset-3" style="background-color:pink;">
adios
</div>
</div>
<div class="row">
<div class="col-xs-6" style="background-color:yellow;">
hola
</div>
<div class="col-xs-3 col-xs-offset-2" style="background-color:pink;">
adios
</div>
</div>
<div class="row">
<div class="col-xs-6" style="background-color:yellow;">
hola
</div>
<div class="col-xs-3 col-xs-offset-1" style="background-color:pink;">
adios
</div>
</div>
</div>
Upvotes: 5