我正在尝试将纯 CSS 框架用于响应式布局。我喜欢他们的垂直菜单,但我不知道如何添加下拉(折叠)子菜单。
我什至无法让他们网站上的水平菜单示例在这里工作:http: //purecss.io/menus/#add-dropdowns-to-menus
垂直菜单是我在项目中采用 Pure 的主要原因,现在我被困住了。
根据 Matthew 的请求,这里是 html 页面的代码。包括所有代码和链接,因此您可以将其加载到浏览器中以最快地理解...
<!doctype html>
<html lang="en">
<head>
<!-- This page uses PURE CSS. See documentation at http://purecss.io/ -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- For HTML5, place favicon.ico and apple-touch-icon(s) in the root directory -->
<!--Add PURE Base, which essentially is built-in Normalize.css,
an HTML5-ready CSS reset with minimal styling. -->
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<!--Add style for vertical menu. -->
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://purecss.io/combo/1.11.5?/css/layouts/side-menu-old-ie.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="http://purecss.io/combo/1.11.5?/css/layouts/side-menu.css">
<!--<![endif]-->
<!--Add yui for second-level menu support. -->
<script src="http://yui.yahooapis.com/3.14.1/build/yui/yui-min.js"></script>
</head>
<body>
<div id="layout">
<!-- Menu toggle -->
<a href="#menu" id="menuLink" class="menu-link">
<!-- Hamburger icon -->
<span></span>
</a>
<div id="menu">
<div class="pure-menu pure-menu-open">
<a class="pure-menu-heading" href="#">Company</a>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li class="menu-item-divided pure-menu-selected">
<a href="#">Services</a>
</li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
<div id="main">
<div class="header">
<h1>Page Title</h1>
<h2>A subtitle for your page goes here</h2>
</div>
<div class="content">
<h2 class="content-subhead">The Layout</h2>
<p>
This is the basic "Side Bar" page design I want to customize. I got it from the Pure CSS <a href="http://purecss.io/layouts/" target="_blank">Layouts page</a>.
</p>
<h2 class="content-subhead">Horizontal Menu Example</h2>
<p>Following is the example <a href="http://purecss.io/menus/#add-dropdowns-to-menus" target="_blank">from Pure CSS Menus page</a> for adding drop-down to horizontal menu:</p>
<div id="demo-horizontal-menu">
<ul id="std-menu-items">
<li class="pure-menu-selected"><a href="#">Flickr</a></li>
<li><a href="#">Messenger</a></li>
<li><a href="#">Sports</a></li>
<li><a href="#">Finance</a></li>
<li>
<a href="#">Other</a>
<ul>
<li class="pure-menu-heading">More from Yahoo!</li>
<li class="pure-menu-separator"></li>
<li><a href="#">Autos</a></li>
<li><a href="#">Flickr</a></li>
<li><a href="#">Answers</a></li>
<li>
<a href="#">Even More</a>
<ul>
<li><a href="#">Horoscopes</a></li>
<li><a href="#">Games</a></li>
<li><a href="#">Jobs</a></li>
<li><a href="#">OMG</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<!-- Script for adding drop-down. -->
<script>
YUI({
classNamePrefix: 'pure'
}).use('gallery-sm-menu', function (Y) {
var horizontalMenu = new Y.Menu({
container : '#demo-horizontal-menu',
sourceNode : '#std-menu-items',
orientation : 'horizontal',
hideOnOutsideClick: false,
hideOnClick : false
});
horizontalMenu.render();
horizontalMenu.show();
});
</script>
<p> </p>
<p> </p>
<p style="color:garnet; font-weight:bold;">I am trying to learn how to add the above submenu functionality to Pure's vertical menu, which displays on the left side of this page.</p>
</div>
</div>
</div>
</body>
<!-- Script to make vertical menu responsive. -->
<script src="http://purecss.io/combo/1.11.5?/js/ui.js"></script>
</html>