响应切换(Responsive Toggle)
优质
小牛编辑
128浏览
2023-12-01
描述 (Description)
data-responsive-toggle属性用于菜单切换。 切换有助于在小屏幕尺寸上显示菜单。
例子 (Example)
以下示例演示了在Foundation中使用响应式导航菜单 -
<!DOCTYPE html>
<html>
<head>
<title>Foundation Template</title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.js"></script>
</head>
<body>
<h2> Example of Responsive Navigation menu</h2>
<div class = "title-bar" data-responsive-toggle = "example-menu" data-hide-for = "medium">
<button class = "menu-icon" type = "button" data-toggle></button>
<div class = "title-bar-title">Menu</div>
</div>
<div id = "example-menu">
<ul class = "menu dropdown" data-dropdown-menu>
<li><a href = "#">Bike</a>
<ul class = "menu">
<li><a href = "#">Bajaj</a></li>
<li><a href = "#">Suzuki</a></li>
<li><a href = "#">Honda</a>
<ul class = "menu">
<li><a href = "#">Activa</a></li>
<li><a href = "#">Dio</a></li>
<li><a href = "#">Passion</a></li>
</ul>
</li>
</ul>
</li>
<li><a href = "#">Car</a></li>
<li><a href = "#">Service</a></li>
<li><a href = "#">Contact</a></li>
</ul>
</div>
<script>
$(document).ready(function() {
$(document).foundation();
})
</script>
</body>
</html>