【发布时间】:2021-09-16 16:21:08
【问题描述】:
我正在学习 bootstrap,并且看到一门专注于 Bootstrap 4 的课程。我不确定以下内容是否与此有关,但我无法完成此练习。
我正在为大屏幕制作这个网格:
当屏幕尺寸缩小到中等时,网格现在应该是这样的:
最后,短屏幕尺寸的屏幕应该是这样的:
我尝试了以下代码,但最大尺寸没有成功:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<style>
div[class^="col"] {
height: 100px;
background: #fdca6d;
border: 1px solid white;
}
</style>
<title>Grid challenge 2</title>
</head>
<body>
<div class="container mt-4">
<!--Start first row-->
<div class="row">
<div class="col-6 col-md-3">
Row 1 / Col 1
</div>
<div class="col-6 col-md-3">
Row 1 / Col 2
</div>
<div class="col-6 col-md-3">
Row 1 / Col 3
</div>
<div class="col-6 col-md-3">
Row 1 / Col 4
</div>
</div>
<!--End first row-->
<!--Start second row-->
<div class="row">
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 1
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 2
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 3
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 4
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 5
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 6
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 7
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 8
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 9
</div>
<div class="col-12 col-md-6 col-lg">
Row 2 / Col 10
</div>
</div>
<!--End second row-->
</div>
<!--Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>
这对我来说是这样的:
【问题讨论】:
-
感谢您的回答。在您的 codeply 代码中,它可以完美运行,但通过 codepen codepen.io/BlancaMorillo/pen/NWjxQQE 对我不起作用。这可能与我称之为引导程序的行有关吗?因为它们在容器内容方面是相同的。
标签: bootstrap-5 bootstrap-grid