Open In App

Foundation CSS Float Center Class

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 to 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.

Foundation CSS Float classes allow us to add common positioning behaviors to elements. Foundation CSS has multiple Float classes such as Float Left, Float Right, and Float Center. In this article, we will learn about the Float Center Class.

The Foundation CSS Float Center class is used to engage the automatic margin centering trick to center align an element inside a <div>. This works only on elements with an absolute width. To use the Float Center effect in Foundation CSS, we use the “float-center” class.

Foundation CSS Float Center Class:

  • float-center: The float-center class aligns the element to the center of the absolute margin of the parent <div>.

Syntax:

<div class="float-center">Content</div>

Example 1: The following example demonstrates the Float center class in the <img> element.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
  
    <!-- Compressed JavaScript -->
    <script src=
    </script>
    <script src=
    </script>
    <style>
        .main{
            width: 700px; 
            Height: 500px; 
            background-color: green;
            padding: 100px;
        }
    </style>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
    <strong>
        Foundation CSS Float Center
    </strong>
    <br/><br/>
    <div class="main">
    <img src=
         class="float-center">
    </div>
</body>
  
</html>


Output:

Output

Example 2: The following example demonstrates the Float center class in the <div> and <img> element inside a card.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
  
    <!-- Compressed JavaScript -->
    <script src=
    </script>
    <script src=
    </script>
    <style>
        .main{
            width: 300px; 
            Height: 300px; 
            padding: 20px;
            background-color: gray;
        }
    </style>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
    <strong>
        Foundation CSS Float Center
    </strong>
    <br/><br/>
    <div class="card main">
        <div class="card-section float-center">
          <p>GeeksforGeeks</p>
        </div>
        <img src=
             class="float-center">
</body>
  
</html>


Output:

Output

Reference: https://get.foundation/sites/docs/float-classes.html#float-center



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