html - 首先如何让 Bootstrap Collapse 隐藏内容?
问题描述
我首先遇到了让 Bootstrap Collapse 隐藏内容的问题?现在我的编码将直接显示标题和内容,我只想先显示标题。
下面是我的编码:
<div class="row">
<div class="col-md-12">
<div class="box box-success box-solid">
<div class="box-header with-border">
<h3 class="box-title">Expandable</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-default btn-xs collapse-box" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div id="collapse4" class="body collapse in" style="overflow: auto;" aria-expanded="true">
A cryptocurrency (or crypto currency) is a digital asset designed to work as a medium of exchange that uses strong cryptography to secure financial transactions, control the creation of additional units, and verify the transfer of assets.
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
<!-- /.col -->
<!-- /.col -->
<!-- /.col -->
</div>
输出显示如下:
实际上我想显示输出隐藏内容,如下图所示,当我单击“加号”按钮时,将显示内容:
任何人都可以指导我错了哪一部分?谢谢。
正确答案:
解决方案
像这样更改您的代码:-
<button type="button" class="btn btn-default btn-xs collapse-box" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample"><i class="fa fa-minus"></i></button>
<div id="collapseExample" class="collapse" style="overflow: auto;">
A cryptocurrency (or crypto currency) is a digital asset designed to work as a medium of exchange that uses strong cryptography to secure financial transactions, control the creation of additional units, and verify the transfer of assets.
</div>
尝试这个
推荐阅读
- swift - 如何使堆栈视图在横向滚动
- xml - 如何使用 XSLT 转换给定的 xml?
- ruby-on-rails - Bundler 找不到兼容版本的 bundler - Ruby On Rails **添加 Carrierwave Gem**
- sql-server - 为什么当我只更改查询中的一个变量时,它需要很长时间才能运行?
- algorithm - 求两条线段之间的距离?
- powershell - Get-ADuser 脚本问题
- python - 在 TensorFlow 2 中使用 tf.ConfigProto 初始化 tf.Session 的等价物是什么?
- javascript - $ 函数在香草(无库)JS 中意味着什么?
- mongodb - 使用 MongoTemplate 聚合过滤 MongoDB 中的嵌套元素
- javascript - 如何根据内部数组属性的过滤来过滤数组?