Foundation 下拉式選單
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> <div style="padding:20px;"> <h2>下拉菜单按钮</h2> <a href="#" data-dropdown="id01" class="button dropdown">Dropdown Button</a> <ul id="id01" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> </div> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
執行實例»
點擊"運行實例" 按鈕查看線上實例
實例解析
#.dropdown
類別為按鈕添加一個向下的箭頭符號"圖標。值需要與下拉式選單的內容(id01) 相符。 # 類別和
屬性來建立下拉式選單的內容。上,所有的下拉式選單的寬度是100%。 ##.medium, .large 或
.mega
下拉式選單邊距
可以使用
.content 類別為下拉式選單新增內邊距:
實例
<!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"> <!-- Tiny Dropdown: max-width is 200px --> <a href="#" data-dropdown="id01" class="button dropdown">Tiny</a> <ul id="id01" data-dropdown-content class="f-dropdown tiny"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <br> <!-- Small Dropdown: max-width is 300px --> <a href="#" data-dropdown="id02" class="button dropdown">Small</a> <ul id="id02" data-dropdown-content class="f-dropdown small"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <br> <!-- Medium Dropdown: max-width is 500px --> <a href="#" data-dropdown="id03" class="button dropdown">Medium</a> <ul id="id03" data-dropdown-content class="f-dropdown medium"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <br> <!-- Large Dropdown: max-width is 800px --> <a href="#" data-dropdown="id04" class="button dropdown">Large</a> <ul id="id04" data-dropdown-content class="f-dropdown large"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <br> <!-- Mega Dropdown: 100% width --> <a href="#" data-dropdown="id05" class="button dropdown">Mega</a> <ul id="id05" data-dropdown-content class="f-dropdown mega"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <!-- Initialize Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例»
#點擊"運行實例" 按鈕查看線上實例其他實例<div> 下拉選單中新增多媒體元素:
#實例
<!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>
<a href="#" data-dropdown="id01" class="button dropdown">没有内边距</a>
<ul id="id01" data-dropdown-content class="f-dropdown">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<a href="#" data-dropdown="id02" class="button dropdown">有内边距</a>
<ul id="id02" data-dropdown-content class="f-dropdown content">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<!-- Initialize Foundation JS -->
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
</body>
</html>
##執行實例»
下拉選單方向
預設情況下下拉選單在底部,可以透過新增
data-options="align:left|right|top"#實例
<!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> <a href="#" data-dropdown="id01" class="button dropdown">下拉按钮</a> <div id="id01" data-dropdown-content class="f-dropdown medium content"> <h4>Paris Title</h4> <p>Some text.. some text..</p> <img src="paris.jpg" alt="Paris" width="400" height="300"> <p>Paris, je t'aime.</p> </div> <!-- Initialize Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
點擊"運行實例" 按鈕查看線上實例
下拉式選單觸發條件
data-options="is_hover: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;"><br><br><!-- Add <br> elements to enable top dropdown --> <h2>下拉菜单方向</h2> <a href="#" data-dropdown="id01" data-options="align:right" class="button dropdown">右边</a> <ul id="id01" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <a href="#" data-dropdown="id02" data-options="align:top" class="button dropdown">顶部</a> <ul id="id02" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <a href="#" data-dropdown="id03" data-options="align:bottom" class="button dropdown">底部</a> <ul id="id03" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <a href="#" data-dropdown="id04" data-options="align:left" class="button dropdown">左边</a> <ul id="id04" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <!-- Initialize Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
運行實例»
點擊"運行實例"按鈕查看線上實例
#分割按鈕
我們可以在按鈕上新增.split
類別來設定一個分割效果的按鈕,分割後會在
<span> 元素上產生一個方向向下的圖示按鈕:
實例
<!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> <a href="#" data-dropdown="id01" data-options="is_hover:true" class="button dropdown">鼠标移动到我这</a> <ul id="id01" data-dropdown-content class="f-dropdown"> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <!-- Initialize Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script> </body> </html>
##執行實例»點擊"運行實例" 按鈕查看線上實例#