简体   繁体   English

平板电脑视图中的折叠面板

[英]collapse panel in tablet view

I have a toolbar. 我有一个工具栏。 When I click on it I have many panels appear on the screen as drop-down. 当我点击它时,屏幕上会出现许多面板作为下拉列表。 In the tablet view I want all the panels to collapse and When I click on the panel-heading I want the panel-body to open. 在平板电脑视图中,我希望所有面板都折叠,当我点击面板标题时,我希望面板体打开。 I am poor in css can anyone help me. 我很穷css任何人都可以帮助我。 Here is the code. 这是代码。

<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
    <div class="panel-body">
        <div class="panel panel-info">
            <div class="panel-heading">
                <a >First heading</a>
            </div>
            <div class="panel-body">
                <ul class="">
                    <li><a >item1</a></li>
                    <li><a >item2</a></li>
                </ul>
            </div>
        </div>
    </div>
    <div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">
        <div class="panel-body">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <a>second heading</a>
                </div>
                <div class="panel-body">
                    <ul class="">
                        <li><a >item4</a></li>
                        <li><a >item3</a></li>
                    </ul>
                </div>
            </div>
        </div>

As you are using bootstrap accordion. 当你使用bootstrap手风琴时。 You need to remove class in from your panel-collapse div . 您需要从panel-collapse div删除class in

Instead of 代替

<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse in" style="height: auto;">

Write

<div class="panel-collapse col-md-2 col-sm-4 col-xs-4 collapse" style="height: auto;">

in is the class, which makes the content panel visible. in是类,它使内容面板可见。 So if you want all the panels collapse, remove it form every panel container. 因此,如果您希望所有面板都折叠,请从每个面板容器中将其删除。 If you want only one panel to be visible while others should be collapsed, then put it in that panel container only. 如果您只想显示一个面板而其他面板应该折叠,则只将其放在该面板容器中。

Let me know if this helps. 如果这有帮助,请告诉我。 :-) :-)

Bootstrap has specialized classes and data-* attributes for these types of tasks. Bootstrap具有针对这些类型任务的专用类和data-*属性。

1) First, in order to make your panel act as an accordion, you need to give: 1)首先,为了使您的面板成为手风琴,您需要给出:

<a data-toggle="collapse" data-target="#panel1">Heading</a>

where panel1 is the id of your panel-body . 其中panel1panel-body的id。

2) Next, since you want your panel-body to be collapsed at first, give the collapse class next to your panel-body : 2)其次,因为你想你的panel-body首先要崩溃了,给collapse旁边类panel-body

<div id="panel1" class="panel-body collapse">

Have a look at the demo here to make things clear. 看看这里的演示 ,让事情变得清晰。

<div class="panel-body columnBody" id="accordion2">
 <div class="panel panel-info">
  <div class="panel-heading">
   <a data-toggle="collapse" data-parent="#accordion" data-target=".Empty">{{item.key}}</a>
   <button class="btn navbar-btn displayMobile" data-parent="#accordion2" data-target=".view{{$index}}"><span class="caret"></span></button>
  </div>
  <div class="panel-body itemList view{{$index}}">
   <ul style="margin-bottom: 0px;">
    <li ng-repeat="ke in item.values"><a href="#about" data-toggle="collapse" data-parent="#accordion" data-target=".Empty">{{ke}}</a></li>
   </ul>
  </div>
 </div>
</div>

css code: css代码:

@media screen and (min-width: 850px){
 .displayMobile{
  display: none;
 }    
 .itemList{
  display: none;
}
}

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

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