是否有一种方法来空间引导卡网格和最大限度?



所以,基本上我在flask中的for循环中有bootstrap卡片。一切都很好,但是当我通过3张牌时,一个新的列开始了,它变得非常烦人。

屏幕截图示例:https://ibb.co/jTvtSbq

甚至连底部的垂直间距看起来都很奇怪。

这是我的HTML代码:

<div class="col">
<div class="card" id='cardPostPost'  style="width: 400px; border-radius: 23px; background-color: rgb(35, 33, 33); color: white; bottom: -22pc; left: -18pc; ">
<h5 class="card-header border-bottom border-light" style="color: white" >Teacher&#39;s Homework</h5>
<div class="card-body" style="color: white" >
<h5 class="card-title">Homework</h5>
<p class="card-text">No </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>

<div class="col">
<div class="card" id='cardPostPost'  style="width: 400px; border-radius: 23px; background-color: rgb(35, 33, 33); color: white; bottom: -22pc; left: -18pc; ">
<h5 class="card-header border-bottom border-light" style="color: white" >SomeNewTask</h5>
<div class="card-body" style="color: white" >
<h5 class="card-title">Homework</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>

<div class="col">
<div class="card" id='cardPostPost'  style="width: 400px; border-radius: 23px; background-color: rgb(35, 33, 33); color: white; bottom: -22pc; left: -18pc; ">
<h5 class="card-header border-bottom border-light" style="color: white" >wdaadadawdawdad</h5>
<div class="card-body" style="color: white" >
<h5 class="card-title">Test</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>

<div class="col">
<div class="card" id='cardPostPost'  style="width: 400px; border-radius: 23px; background-color: rgb(35, 33, 33); color: white; bottom: -22pc; left: -18pc; ">
<h5 class="card-header border-bottom border-light" style="color: white" >wdadwadadadwadawdad</h5>
<div class="card-body" style="color: white" >
<h5 class="card-title">Test</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>

</div>
</div>

有人知道如何解决这个问题吗?

  1. 你必须在每张卡片中制作父<div class="col">
  2. 移除width: 400px; bottom: -22pc; left: -18pc;

完整代码如下-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row row-cols-auto g-4">
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">Teacher&#39;s Homework</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">No </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">SomeNewTask</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">SomeNewTask</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">SomeNewTask</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">SomeNewTask</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">Yes </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">Teacher&#39;s Homework</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">No </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">Teacher&#39;s Homework</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">No </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
<div class="col">
<div class="card" id='cardPostPost'
style=" border-radius: 23px; background-color: rgb(35, 33, 33); color: white;">
<h5 class="card-header border-bottom border-light" style="color: white">Teacher&#39;s Homework</h5>
<div class="card-body" style="color: white">
<h5 class="card-title">Homework</h5>
<p class="card-text">No </p>
<a href="#" class="btn btn-primary">Learn More</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

相关内容

  • 没有找到相关文章

最新更新