简体   繁体   English

在 bootstrap col 下打开新的 div

[英]Open new div below bootstrap col

Let's suppose I have the following table in bootstrap:假设我在引导程序中有下表:

在此处输入图片说明

And I want to open a div with more information below the col when I click it:当我单击它时,我想在 col 下面打开一个包含更多信息的 div:

在此处输入图片说明

Is this possible to do with css/javascript?这可能与css/javascript有关吗? I have tried the Metro Dropdown but the opened div is being constrained by the col-3 width.我尝试过Metro Dropdown,但打开的 div 受到 col-3 宽度的限制。 I have also tried to set the width for this div in css, but I can't seem to reach a result similar to the image attached.我也尝试在 css 中设置这个 div 的宽度,但我似乎无法达到与附加图像类似的结果。

What is the name of a behaviour like this?这种行为的名称是什么? It seems like a "Dropdown" that push the bellow components a bit down.这似乎是一个“下拉”,将波纹管组件向下推一点。 How do I do something like this?我怎么做这样的事情?

As I mentioned above, there are some missing specifications in your question.正如我上面提到的,您的问题中缺少一些规范。 Here's a stab at it.这是一个尝试。 If it's off the mark, update your question with more detail and leave a comment.如果它不合时宜,请用更多细节更新您的问题并发表评论。

 $(document).ready(function() { let counter = 1; $('.container-fluid').fadeIn(); $('.col-12').click(function() { // slide up existing detail row with animation, then remove it $(this).closest('.row').find('.detail').slideUp(400, function() { $(this).remove(); }); // create and append a new row with animation let detailEl = $('<div class="col-12 detail hidden">' + counter + '</div>'); $(this).closest('.row').append(detailEl) detailEl.slideDown(); counter++; }); });
 .row { border-bottom: 2px solid #ddd; } .col-12, .detail { height: 30px; background: pink; } .detail { background: lightgreen; transition: background 1s; } .detail+.detail { background: darkgreen; } .hidden { display: none; }
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="container-fluid hidden"> <div class="row"> <div class="col-12"></div> </div> <div class="row"> <div class="col-12"></div> </div> </div>

Fiddle demo小提琴演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM