Materialise提供了各種CSS類,以對(duì)顯示各種類型的折疊應(yīng)用各種預(yù)定義的視覺(jué)和行為增強(qiáng)。下表提到了可用的類及其效果。
序號(hào) | 類名稱及說(shuō)明 |
---|---|
1 | collapsible 將元素標(biāo)識(shí)為實(shí)現(xiàn)可折疊組件。 ul元素必需。 |
2 | collapsible-header 將div設(shè)置為段標(biāo)題。 |
3 | collapsible-body 將div設(shè)置為節(jié)內(nèi)容容器。 |
4 | popout 創(chuàng)建可折疊的彈出窗口。 |
5 | active 打開(kāi)一個(gè)部分。 |
6 | expandable 將可折疊組件標(biāo)記為可展開(kāi)。 |
7 | accordion 將可折疊組件標(biāo)記為手風(fēng)琴。 |
以下是以不同方式使用手風(fēng)琴的例子。
materialize_collapsible.html
<html> <head> <title>The Materialize Collapsible Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css"> <script type="text/javascript" src="/attachments/tuploads/materialize/jquery-2.1.1.min.js"></script> <script src="/attachments/tuploads/materialize/materialize.min.js"></script> </head> <body class="container"> <h4>Simple Accordion</h4> <ul class="collapsible" data-collapsible="accordion"> <li> <div class="collapsible-header"><i class="material-icons">filter_drama</i>First Section</div> <div class="collapsible-body"><p>This is first section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">place</i>Second Section</div> <div class="collapsible-body"><p>This is second section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">whatshot</i>Third Section</div> <div class="collapsible-body"><p>This is third section.</p></div> </li> </ul> <h4>Popout Accordion</h4> <ul class="collapsible popout" data-collapsible="accordion"> <li> <div class="collapsible-header"><i class="material-icons">filter_drama</i>First Section</div> <div class="collapsible-body"><p>This is first section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">place</i>Second Section</div> <div class="collapsible-body"><p>This is second section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">whatshot</i>Third Section</div> <div class="collapsible-body"><p>This is third section.</p></div> </li> </ul> <h4>Accordion with Preselected Section</h4> <ul class="collapsible" data-collapsible="accordion"> <li> <div class="collapsible-header"><i class="material-icons">filter_drama</i>First Section</div> <div class="collapsible-body"><p>This is first section.</p></div> </li> <li> <div class="collapsible-header active"><i class="material-icons">place</i>Second Section</div> <div class="collapsible-body"><p>This is second section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">whatshot</i>Third Section</div> <div class="collapsible-body"><p>This is third section.</p></div> </li> </ul> <h4>Expandables</h4> <ul class="collapsible" data-collapsible="expandable"> <li> <div class="collapsible-header"><i class="material-icons">filter_drama</i>First Section</div> <div class="collapsible-body"><p>This is first section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">place</i>Second Section</div> <div class="collapsible-body"><p>This is second section.</p></div> </li> <li> <div class="collapsible-header"><i class="material-icons">whatshot</i>Third Section</div> <div class="collapsible-body"><p>This is third section.</p></div> </li> </ul> </body> </html>
驗(yàn)證結(jié)果,如下圖所示。
更多建議: