在盒子的右边,没有边距。我知道它应该覆盖屏幕的整个水平宽度,但是为什么我们可以在容器的左边应用边距呢?
<!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/bootstrap@4.6.2/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/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>
我也知道有一个叫做container的类,但是当我缩小视口时,它会从一个特定的宽度跳到另一个宽度,我想知道是否有一种方法可以确保它像container-fluid一样平滑,但是增加了边距。
1条答案
按热度按时间fgw7neuy1#
使用正确的语法row和col
检查bootstrap中的间距:
Spacing, How it works