提问人:EnderNicky 提问时间:11/13/2023 最后编辑:EnderNicky 更新时间:11/13/2023 访问量:41
Bootstrap 5 卡根据内部元素的存在更改顺序 [关闭]
Bootstrap 5 card changes order depending on presence of inner elements [closed]
问:
有点奇怪的行为,我在 bootstrap 5 文档中找不到解释。
如果你从这里拿他们的示例卡
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<a href="/">
<div class="card mb-3" style="max-width: 540px;">
<div class="row no-gutters">
<div class="col-md-4">
<img src="https://via.placeholder.com/300x100" class="card-img" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
</div>
</div>
</a>
</body>
只需在它周围添加一个链接元素,它就可以正常工作 - 显示您期望的内容:
但是,如果我们采用完全相同的代码并在 card-body div 中添加一个 a 元素(在哪里并不重要 - 这里我把它放在正文的末尾):
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<a href="/">
<div class="card mb-3" style="max-width: 540px;">
<div class="row no-gutters">
<div class="col-md-4">
<img src="https://via.placeholder.com/300x100" class="card-img" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<a></a>
</div>
</div>
</div>
</div>
</a>
</body>
想知道有人会对此进行解释以及我如何解决它的想法吗?
答: 暂无答案
评论