如何使引导程序崩溃平滑
Posted
技术标签:
【中文标题】如何使引导程序崩溃平滑【英文标题】:how to make a bootstrap collapse smooth 【发布时间】:2021-10-06 15:48:01 【问题描述】:我这里有这段代码。正如你所看到的,当内容崩溃时,在内容崩溃之前会有一个轻弹。我需要它顺利折叠。
<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>
【问题讨论】:
【参考方案1】:将您的内容包装到 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>
【讨论】:
以上是关于如何使引导程序崩溃平滑的主要内容,如果未能解决你的问题,请参考以下文章