gpt4 book ai didi

css - bootstrap 4 中的合理嵌套按钮组

转载 作者:行者123 更新时间:2023-11-28 15:06:40 26 4
gpt4 key购买 nike

我有一个像这样的按钮组控件。

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div role="group" class="d-flex btn-group">
<button type="button" class="w-100 btn btn-outline-secondary"><i class="fas fa-print"></i></button>
<div role="group" class="dropdown btn-group">
<button aria-haspopup="true" aria-expanded="false" type="button" class="dropdown-toggle btn btn-outline-secondary"><i class="fas fa-download"></i></button>
<div aria-labelledby="" class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 32px, 0px);"><a class="w-100 dropdown-item" role="button" href="#">Dropdown link</a><a class="w-100 dropdown-item" role="button" href="#">Dropdown link</a></div>
</div>
<button type="button" class="w-100 btn btn-outline-secondary"><i class="fas fa-th"></i></button><button title="Clear" type="button" class="w-100 btn btn-outline-secondary"><i class="fas fa-eraser"></i></button>
</div>

嵌套按钮组没有像其他按钮那样占用可用宽度。

我也试过给 w-100 但没有帮助。

最佳答案

请检查下面的代码,它可能对你有帮助

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<style>
.btn-group .col-6-cus { width:50% !important;}
.btn-group .col-6-cus .dropdown-toggle { width:100%;}
</style>

</head>

<body>


<div role="group" class="d-flex btn-group">
<button type="button" class="w-100 col-6-cus btn btn-outline-secondary"><i class="fas fa-print"></i></button>
<div role="group" class="dropdown btn-group col-6-cus">
<button aria-haspopup="true" aria-expanded="false" type="button" class="dropdown-toggle btn btn-outline-secondary"><i class="fas fa-download"></i></button>
<div aria-labelledby="" class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 32px, 0px);"><a class="w-100 dropdown-item" role="button" href="#">Dropdown link</a><a class="w-100 dropdown-item" role="button" href="#">Dropdown link</a></div>
</div>
<button type="button" class="w-100 btn btn-outline-secondary col-6-cus"><i class="fas fa-th"></i></button>
<button title="Clear" type="button" class="w-100 btn btn-outline-secondary col-6-cus"><i class="fas fa-eraser"></i></button>
</div>

</body>
</html>

关于css - bootstrap 4 中的合理嵌套按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56168778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com