我正在使用Bootstrap3并在我的设计中使用可折叠元素。
<!-- Search Filter -->
<div id="search-filter">
<div class="container">
<div class="row">
<div class="col-md-5 col-xs-12">
<!-- Collapse Search -->
<button type="button" class="navbar-toggle navbar-toggle-search-filter" data-toggle="collapse" data-target="#searchbar-collapse-set"> <span class="sr-only">Toggle navigation</span> <span class="glyphicon glyphicon-chevron-down"></span> </button>
<!-- /Collapse Search -->
<h3>Showing 345 Results <small>(Hill Stations around Bangalore)</small></h3>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="searchbar-collapse-set">
<div class="col-md-4 col-xs-12">
<div class="distance">
<h5>distance:</h5>
<div id="distance-slider"></div>
<span class="distance-value">250 kms</span>
</div>
</div>
<div class="col-md-3 col-xs-12">
<div class="sort">
<h5>sort:</h5>
<ul class="nav nav-pills">
<li class="active"><a href="#">popular</a></li>
<li><a href="#">name</a></li>
<li><a href="#">distance</a></li>
</ul>
</div>
</div>
</div>
<!-- /.navbar-collapse -->
<div class="clearfix"></div>
</div>
</div>
</div>
<!-- /Search Filter -->
我如何使用Media-Query或JS默认在较小的设备上打开它?
答案 0 :(得分:3)
添加&#34; in&#34;类似于你的searchbar-collapse-set div:
<div class="navbar-collapse collapse in" id="searchbar-collapse-set">
修改强>
切换由媒体查询控制。在此规则中,它的显示在768px处设置为无:
@media (min-width: 768px) {
.navbar-toggle {
display: none;
}
}
因此,您可以覆盖自己样式中的规则,也可以自定义Bootstrap css文件。