On the right side of the box, theres no margin.I get that its suppose to cover the entire horizontal width of the screen, but then why can we apply the margin on the left side of container?
<!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://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container-fluid" style="background-color:pink;padding:15%; margin:15%;">
<h1>My First Bootstrap Page</h1>
<p>This part is inside a .container-fluid class.</p>
<p>The .container-fluid class provides a full width container, spanning the entire width of the viewport.</p>
</div>
</body>
</html>
Also I know there is class called container, but it jumps from a specific width to another width when i reduce the viewport, i was wondering if there a way to make sure it goes smoothly like container-fluid but with the added margins.
2
Answers
use the right syntax with row and col
Check this for spacing in bootstrap:
Spacing, How it works
You can do it without bootstrap pure css
Create a wrapper div
Flex without container
Container with flex, center vertically and horizontally and a div