在 Bootstrap 4 中,如何创建一个垂直堆叠的按钮列表,其中每个按钮包含两列左对齐文本?
问问题
205 次
1 回答
0
通过使用 btn-block,我能够将按钮扩展到其父容器的宽度:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<style>
button span {
float:left;
width: 50%;
text-align:left;
}
.btn-group-vertical {
justify-content: flex-start;
}
</style>
<h1 class="text-center">Two Left-Aligned Columns of Buttons in Bootstrap 4</h1>
<div class="container">
<div class="row">
<div class="col-2 col-sm-3 btn-group-vertical" role="group" aria-label="Vowels">
<button type="button" class="btn btn-sm btn-block btn-outline-dark border-light">
<span>text</span>
<span>text</span>
</button>
<button type="button" class="btn btn-sm btn-block btn-outline-dark border-light">
<span>more text</span>
<span>more text</span>
</button>
</div>
<div class="col-4 col-sm-3 btn-group-vertical" role="group" aria-label="Vowels">
<button type="button" class="btn btn-sm btn-block btn-outline-dark border-light">
<span>text</span>
<span>text</span>
</button>
<button type="button" class="btn btn-block btn-sm btn-outline-dark border-light">
<span>text</span>
<span>more text</span>
</button>
<button type="button" class="btn btn-block btn-sm btn-outline-dark border-light">
<span>text</span>
<span>even more text</span>
</button>
</div>
</div>
</div>
</body>
</html>
于 2020-06-05T22:44:17.327 回答