如何使bootstrap崩溃平滑

i86rm4rw  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(135)

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

<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>
xmakbtuz

xmakbtuz1#

将您的内容物 Package 到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>

相关问题