Foundation sidebar


Sidebar Navigation

Foundation Use <ul class="side-nav"> Create a sidebar:

Example

<!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>

<ul class="side-nav">
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 2</a></li>
  <li><a href="#">Link 3</a></li>
  <li><a href="#">Link 4</a></li>
</ul>

<div style="padding:20px;">
  <h3>侧栏导航</h3>
  <p> .side-nav 类用于创建侧栏导航,宽度为父元素100%宽度。</p>
</div>

</body>
</html>

Run instance»

Click the "Run instance" button to view the online instance

Activate link and dividing line

The clicked link can be identified using the .active class on <li>, and the .divider class is used to add a horizontal dividing line:

Instance

<!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>

<ul class="side-nav">
  <li class="active"><a class="a" href="#">Link 1</a></li>
  <li><a class="a" href="#">Link 2</a></li>
  <li class="divider"></li>
  <li><a class="a" href="#">Link 3</a></li>
  <li><a class="a" href="#">Link 4</a></li>
</ul>

<div style="padding:20px;">
  <h3>侧栏导航</h3>
  <p> .active 类用于设置当期页链接。</p>
  <p> .divider 类用于设置水平的分割线。</p>
</div>

</body>
</html>

Run Instance»

Click the "Run Instance" button to view the online instance


Sidebar in Grid

We can use the grid design pattern to set up the side navigation bar. The example is as follows:

Example

<!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 class="row">
  <div class="medium-4 columns" style="background-color:#f1f1f1;">
    <ul class="side-nav">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Learn HTML</a></li>
      <li><a href="#">Learn JavaScript</a></li>
      <li><a href="#">Learn CSS</a></li>
      <li><a href="#">Learn Foundation</a></li>    
      <li><a href="#">Learn HTML</a></li>
      <li><a href="#">Learn JavaScript</a></li>
      <li><a href="#">Learn CSS</a></li>
      <li><a href="#">Learn Foundation</a></li>      
    </ul>
  </div>
  <div class="medium-8 columns">
    <h1>侧栏导航</h1>
    <p>该实例将侧栏导航房子网格设计中,背景为灰色。</p>
    <p><strong>注意:</strong> 在小屏幕尺寸上,侧栏导航是垂直的,且宽度是延展到整个屏幕(100% width)。</p>
    <p>重置浏览器查看效果。</p>
    <p>行为动作可以通过 javascript 或媒体查询来修改它。</p>
  </div>
</div>

</body>
</html>

Run Instance»

Click the "Run Instance" button to view the online instance