Home Development Mastering the Essentials of the Foundation Framework

Mastering the Essentials of the Foundation Framework

by admin

thumbnailIf you’re unfamiliar with the Foundation framework, now’s a perfect time to learn. With the recent launch of its fourth iteration, the framework continues to impress with its mobile-first approach and a suite of features that enhance the grid system beyond its competitors.

Foundation has been reimagined since its third release using SASS — a tool that makes writing CSS more streamlined and efficient. This fresh version prides itself not only on being fully responsive but also on offering extensive flexibility and customizability within its grid system.

Let’s plunge into the features of Foundation and discover why it’s a choice tool for web developers…

Understanding the Grid

The grid in Foundation is a 12-column setup that’s fully nestable and adjusts seamlessly to fit any screen size. For those who have worked with grid systems before, Foundation’s approach will feel intuitive. The use of box-sizing: border-box in div elements simplifies width and height calculations by including padding and borders. What makes Foundation’s grid stand out is its dual-scale system: a standard grid for screens wider than 768px and a smaller scale for narrower screens. Use the ‘small-#’ and ‘large-#’ classes to take full control of your layout:

<div class="row">
 <div class="small-3 large-4 columns">Sample Text</div>
 <div class="small-3 large-4 columns">Sample Text</div>
 <div class="small-6 large-4 columns">Sample Text</div>
</div>

In this example, we have three divs that display equal widths on a browser larger than 768px. On narrower screens, the classes adjust so that the final div takes up half the width, while the first two share the remaining space equally. This ensures our websites look impeccable across all devices.

To make columns float right or create space between them, you can add an offset to any column using either ‘large-offset’ or ‘small-offset’ classes:

<div class="row">
 <div class="large-3 columns"></div>
 <div class="large-3 large-offset-6 columns">3, offset by 6</div>
</div>

The Block Grid

The block grid is a clever feature that evenly distributes list content across the grid. By using the ‘small-block-grid’ and ‘large-block-grid’ classes, you can maintain consistent spacing across varying viewing sizes. Here’s how you can apply both for increased control:

<ul class="small-block-grid-2 large-block-grid-4">
 <li><img src="image1.png"></li>
 <li><img src="image2.png"></li>
 <li><img src="image3.png"></li>
 <li><img src="image4.png"></li>
</ul>

This structure allows for a neat and even layout, adapting to one or two rows, depending on the screen size.

Navigating Main Menus

Focusing on navigation, let’s explore how Foundation simplifies the creation of flexible and user-friendly menus. A standard responsive navigation bar is built using simple Foundation classes:

<nav class="top-bar">
 <ul class="title-area">
 <li class="name">
 <h1><a href="/">Your Website Name</a></h1>
 </li>
 <li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li>
 </ul>
 <section class="top-bar-section">
    <ul class="right">
	 <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>
</section>
</nav>

This code produces a sleek navigation bar with a brand title on the left and menu items on the right. On smaller screens, the menu collapses into a more mobile-friendly icon. Add the ‘fixed’ class for sticky positioning on scroll and ‘has-dropdown’ for dropdown menus.

Buttons & Styles

A variety of button styles are pre-configured within Foundation. From ‘success’ to ‘alert’, buttons come in multiple colors that signify different actions. The ‘radius’ and ’round’ classes add border-radiuses for subtle to dramatic rounded corners. Size variations and the ‘disabled’ class enable further customization to tailor buttons to any design:

<!-- Size Variations -->
<a href="#" class="button">Default Button</a>
<a href="#" class="tiny button">Tiny Button</a>
<a href="#" class="small button">Small Button</a>
<a href="#" class="large button">Large Button</a>

<!-- Color Variations -->
<a href="#" class="button secondary">Secondary Button</a>
<a href="#" class="button success">Success Button</a>
<a href="#" class="button alert">Alert Button</a>

<!-- Shape Variations -->
<a href="#" class="button radius">Radius Button</a>
<a href="#" class="button round">Round Button</a>

<!-- Disabled State -->
<a href="#" class="button disabled">Disabled Button</a>

To craft a dropdown button, simply append the ‘dropdown’ class:

<a href="#" class="button dropdown">Dropdown Button</a>

Typography & Lists

Foundation typographic conventions are rooted in Helvetica Neue, with ’em’ units replacing pixels for scalability. Using header tags is straightforward, and additional classes like ‘subheader’ and segment headers provide further typographical distinction. For lists, both circle and square bullet styles are available—use the ‘disc’ or ‘square’ class, respectively. To line up list items horizontally, apply the ‘inline-list’ class:

<!-- Headers -->
<h1 class="subheader">h1.subheader</h1>
<h1>Main Header <small>Sub Header</small></h1>

<!-- Bullet Styles -->
<ul class="circle">
 <li>Bullet Item</li>
</uL>
<ul class="square">
 <li>Square Bullet Item</li>
</uL>

<!-- Inline Lists -->
<ul class="inline-list">
 <li><a href="#">Inline List 1</a></li>
 <li><a href="#">Inline List 2</a></li>
</ul>

Other Fascinating Features

Delve deeper into Foundation to uncover a treasure trove of additional CSS and JavaScript components that further enrich the framework:

  • Interactive Alert Boxes
  • Classy Panels
  • Stylish Pricing Tables
  • Animated Progress Bars
  • Sortable Tables
  • Responsive Thumbnails
  • Optimized Flex Video

And don’t miss the handy JavaScript helpers, such as:

  • Image Clearance
  • Dropdown Enhancements
  • Interactive Joyride
  • Sticky Magellan
  • Orbit Sliders
  • Modal Reveal
  • Accordion Section
  • Informative Tooltips

With all these features at your disposal, exploring Foundation is both exciting and educational, offering a wealth of options for CSS and JavaScript functionality.

Final Thoughts

We’ve only scratched the surface of Foundation’s capabilities which can revolutionize the way we build fast, responsive sites. The framework’s grid system allows for unprecedented control over layouts, while a plethora of helper elements and styles streamline website creation. Embark on your journey with Foundation for your next project, and experience its robustness first-hand.

Have you woven Foundation into your web projects? Which features have elevated your designs? Share your experiences in the comments.

Related Posts

Leave a Comment