Open In App

Foundation CSS Top Bar Stacking

Improve
Improve
Like Article
Like
Save
Share
Report

Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on SaaS-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices.

Top Bar is essential for every website. It allows us to navigate among various pages. Foundation CSS offers a foundation-styled Top Bar. By default, the elements in Top Bar stack upon each other as the information cannot be accommodated on smaller screens. Foundation CSS allows us to change the stacking functionality of the top bar for various other screen sizes by using the reserved classes.

Foundation CSS Top Bar Stacking Classes:

  • stacked-for-medium: Stacks the elements of the top bar upon each other for medium-sized and small-sized screens.
  • stacked-for-large: Stacks the elements of the top bar upon each other on large, medium, and small screens.

Syntax:

<div class="top-bar Top-Bar-Stacking-Class">
  ...
</div>

Example 1: In the below example, we have created a basic top bar that stacks on large, medium, and small screens.

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Foundation CSS Top Bar Stacking</title>
    <!-- Compressed CSS -->
    <link
      rel="stylesheet"
          href=
    <link
      rel="stylesheet"
          href=
"//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.min.css"/>
    <!-- Compressed JavaScript -->
    <script src=
    </script>
    <script src=
    </script>
  </head>
  
  <body style="height: 95vh; width: 100vw">
    <div>
      <h2 style="color: green">GeekforGeeks</h2>
      <h4>Foundation CSS Top Bar Stacking</h4>
      <div class="top-bar stacked-for-large">
        <div class="top-bar-left">
          <ul class="menu">
            <li style="color: green"
                class="menu-text">GeekforGeeks</li>
            <li><a href="#">Python</a></li>
            <li><a href="#">JavaScript</a></li>
            <li><a href="#">Java</a></li>
          </ul>
        </div>
        <div class="top-bar-right">
          <ul class="menu">
            <li><a href="#">Blockchain</a></li>
            <li><a href="#">Data Mining</a></li>
          </ul>
        </div>
        <div class="top-bar-right">
          <ul class="menu">
            <li><input type="search"
                       placeholder="Search" /></li>
            <li><button type="button"
                        class="button">Search</button></li>
          </ul>
        </div>
      </div>
    </div>
    <script>
      $(document).ready(function () {
        $(document).foundation();
      });
    </script>
  </body>
</html>


Output:

Foundation CSS Top Bar Stacking

Foundation CSS Top Bar Stacking

Example 2: In the below example, we have created a basic top bar that stacks on medium and small screens.

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Foundation CSS Top Bar Stacking</title>
    <!-- Compressed CSS -->
    <link rel="stylesheet" 
          href=
    <link rel="stylesheet"
          href=
"//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.min.css"/>
    <!-- Compressed JavaScript -->
    <script src=
    </script>
    <script src=
    </script>
  </head>
  
  <body style="height: 95vh; width: 100vw">
    <div>
      <h2 style="color: green">GeekforGeeks</h2>
      <h4>Foundation CSS Top Bar Stacking</h4>
      <div class="top-bar stacked-for-medium">
        <div class="top-bar-left">
          <ul class="menu">
            <li><input type="search" 
                       placeholder="Search" /></li>
            <li><button type="button"
                        class="button">Search</button></li>
          </ul>
        </div>
        <div class="top-bar-left">
          <ul class="menu">
            <li><a href="#">Blockchain</a></li>
            <li><a href="#">Data Mining</a></li>
          </ul>
        </div>
        <div class="top-bar-right">
          <ul class="menu">
            <li><a href="#">Python</a></li>
            <li><a href="#">JavaScript</a></li>
            <li><a href="#">Java</a></li>
          </ul>
        </div>
      </div>
    </div>
    <script>
      $(document).ready(function () {
        $(document).foundation();
      });
    </script>
  </body>
</html>


Output:

Foundation CSS Top Bar Stacking

Foundation CSS Top Bar Stacking

Reference: https://get.foundation/sites/docs/top-bar.html#stacking



Last Updated : 07 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads