gpt4 book ai didi

javascript - 如何使 Bootstrap 崩溃平滑

转载 作者:行者123 更新时间:2023-12-04 07:19:18 25 4
gpt4 key购买 nike

我这里有这个代码。正如您所看到的,当内容折叠时,在内容折叠之前会有一个轻弹。我需要它顺利崩溃。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>


<div class="container">
<h2>Simple Collapsible</h2>
<p>Click on the button to toggle between showing and hiding content.</p>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">Simple collapsible</button>
<div id="demo" class="collapse in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div><br>
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo2">Simple collapsible</button>
<div id="demo2" class="collapse in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>

最佳答案

将您的内容包装到 2 个容器中 div并删除 br (或将 br 放在容器外 div )

<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo2">
Simple collapsible
</button>
<div id="demo2" class="collapse in">Lorem ...</div>
</div>
<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo2">
Simple collapsible
</button>
<div id="demo2" class="collapse in">Lorem...</div>
</div>
例子:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
<h2>Simple Collapsible</h2>
<p>Click on the button to toggle between showing and hiding content.</p>

<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">
Simple collapsible
</button>
<div id="demo" class="collapse in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo2">
Simple collapsible
</button>
<div id="demo2" class="collapse in">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
</div>

</body>
</html>

关于javascript - 如何使 Bootstrap 崩溃平滑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68602132/

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