Open In App

Foundation CSS JavaScript Programmatic Use

Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on Bootstrap, which is similar to SaaS. It’s more complex, versatile, and configurable. It also comes with a command-line interface, making it simple to use with module bundlers. Email framework provides you with responsive HTML emails, which can be read on any device. Foundation for Apps allows you to build fully responsive web applications.

Foundation CSS and JavaScript can be used for programmatic use in an HTML document by including the necessary CSS and JavaScript files and initializing the plugins.



Syntax:

<script>
    $(document).foundation();
</script>

 



Example 1: This code of Foundation CSS and JavaScript is for programmatic use in an HTML document.




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
"width=device-width, initial-scale=1.0">
  <title>Foundation CSS and JavaScript Programmatic Use</title>
  <!-- Link to Foundation CSS -->
  <script src=
        integrity=
"sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" 
        crossorigin="anonymous">
    </script>
  
  <link rel="stylesheet" href=
        integrity=
"sha256-ogmFxjqiTMnZhxCqVmcqTvjfe1Y/ec4WaRj/aQPvn+I=" 
        crossorigin="anonymous">
  <!-- Link to Foundation JavaScript -->
  <script src=
            integrity=
"sha256-pRF3zifJRA9jXGv++b06qwtSqX1byFQOLjqa2PTEb2o=" 
            crossorigin="anonymous">
    </script>
</head>
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h3>Foundation CSS JavaScript Programmatic Use</h3>
        <!-- Use Foundation's JavaScript to toggle a dropdown menu -->
        <button class="button" data-toggle="example-dropdown">
            Toggle Dropdown
        </button>
        <div class="dropdown-pane" id="example-dropdown" 
            data-dropdown>
            <p>This is a dropdown menu</p>
            <ul>
                <li><a href="#">Menu item 1</a></li>
                <li><a href="#">Menu item 2</a></li>     
            </ul>
        </div>
  
        <!-- Initialize Foundation JavaScript plugins -->
        <script>
            $(document).foundation();
        </script>
    </center>
</body>
</html>

Output:

 

Example 2: This code with Foundation CSS and JavaScript in an HTML document,  demonstrates the use of the responsive tabs plugin.




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
"width=device-width, initial-scale=1.0">
  <title>Foundation CSS and JavaScript Programmatic Use</title>
  <!-- Link to Foundation CSS -->
  <script src=
        integrity=
"sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" 
        crossorigin="anonymous">
    </script>
  
  <link rel="stylesheet" href=
        integrity=
"sha256-ogmFxjqiTMnZhxCqVmcqTvjfe1Y/ec4WaRj/aQPvn+I=" 
        crossorigin="anonymous">
  <!-- Link to Foundation JavaScript -->
  <script src=
            integrity=
"sha256-pRF3zifJRA9jXGv++b06qwtSqX1byFQOLjqa2PTEb2o=" 
            crossorigin="anonymous">
    </script>
    <style>
        body{
           margin-left:10px;
           margin-right:10px;
        }
    </style>
</head>
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h3>Foundation CSS JavaScript Programmatic Use</h3>
        <!-- Use Foundation's responsive tabs plugin -->
        <ul class="tabs" data-responsive-accordion-tabs=
            "tabs small-accordion medium-tabs" 
            id="example-tabs">
            <li class="tabs-title is-active">
                <a href="#panel1" aria-selected="true">
                    Tab 1</a>
            </li>
            <li class="tabs-title">
                <a href="#panel2">
                    Tab 2</a>
            </li>          
        </ul>
        <div class="tabs-content" 
            data-tabs-content="example-tabs">
            <div class="tabs-panel is-active" 
                id="panel1">
              <p>Content for tab 1</p>
            </div>
            <div class="tabs-panel" id="panel2">
              <p>Content for tab 2 </p>
            </div>            
        </div>
    </center>
    <!-- Initialize Foundation JavaScript plugins -->
    <script>
        $(document).foundation();
    </script>
</body>
</html>

Output:

 

Reference: https://get.foundation/sites/docs/javascript.html#programmatic-use


Article Tags :