Foundation 折疊列表
在你想要隱藏部分內容的顯示時,可以使用折疊清單。
實例
<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px"> <h2>可折叠实例</h2> <ul class="accordion" data-accordion> <li class="accordion-navigation"> <a href="#demo">简单的可折叠实例</a> <div id="demo" class="content"> php中文网 -- php中文网!! </div> </li> </ul> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例»
點擊"運行實例" 按鈕查看線上實例
實例解析
.accordion
類別和data-accordion
屬性用於建立一個可折疊的元素。 .accordion-navigation
類別用於渲染可折疊元素。實際的內容在 .content
類別 (<div class="content") 中,點擊按鈕可以顯示。
我們在清單項目中加入 <a>
元素來控制(顯示/隱藏)可折疊的內容。然後錨連結使用與可折疊內容內容相同的id (<a href=#demo" 與 <div
id="demo"> 相關聯)。
注意: 可折疊的效果需要初始化 Foundation JS。
預設情況下,可折疊內容是隱藏的。我們可以透過在<div>
上新增.active
類別讓其預設是顯示的:
實例
##<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px"> <h2>可折叠实例</h2> <ul class="accordion" data-accordion> <li class="accordion-navigation"> <a href="#demo">简单的可折叠实例</a> <div id="demo" class="content active"> php中文网 -- php中文网!! </div> </li> </ul> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例»點擊"運行實例"按鈕查看線上實例
手風琴效果手風琴效果用於延展與設定可折疊內容。 手風琴效果透過使用多個不同的錨點連結與id來建立:
實例
運行實例» 點擊"運行實例" 按鈕查看線上實例
預設情況下,手風琴列表項目有一個是開啟的。如果你想關閉所有可以使用<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px"> <h2>手风琴实例</h2> <ul class="accordion" data-accordion> <li class="accordion-navigation"> <a href="#demo">手风琴 1</a> <div id="demo" class="content active"> Demo 1 - php中文网 -- php中文网!! </div> </li> <li class="accordion-navigation"> <a href="#demo2">手风琴 2</a> <div id="demo2" class="content"> Demo 2 - php中文网 -- php中文网!! </div> </li> <li class="accordion-navigation"> <a href="#demo3">手风琴 3</a> <div id="demo3" class="content"> Demo 3 - php中文网 -- php中文网!! </div> </li> </ul> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例» 點擊"運行實例" 按鈕查看線上實例
data-options="multi_expand:true;" 屬性:
實例
<!DOCTYPE html> <html> <head> <title>Foundation 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://static.php.cn/assets/foundation-5.5.3/foundation.min.css"> <script src="http://static.php.cn/assets/jquery/2.0.3/jquery.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/foundation.min.js"></script> <script src="http://static.php.cn/assets/foundation-5.5.3/js/vendor/modernizr.js"></script> </head> <body style="padding:20px"> <h2>手风琴实例</h2> <ul class="accordion" data-accordion data-options="multi_expand:true;"> <li class="accordion-navigation"> <a href="#demo">手风琴实例 1</a> <div id="demo" class="content"> Demo 1 - php中文网 -- php中文网!! </div> </li> <li class="accordion-navigation"> <a href="#demo2">手风琴实例 2</a> <div id="demo2" class="content"> Demo 2 - php中文网 -- php中文网!! </div> </li> <li class="accordion-navigation"> <a href="#demo3">手风琴实例 3</a> <div id="demo3" class="content"> Demo 3 - php中文网 -- php中文网!! </div> </li> </ul> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>