Home > AI > Language > CSS >

float

The float element will be seperated from the dom and its height will be ignored for the following elements.

Example:

<!DOCTYPE html>
<html>
  <head>
    <title>Parcel Sandbox</title>
    <meta charset="UTF-8" />
  </head>
 
  <style>
    p {
      white-space: normal;
    }
    img {
      width: 100px;
    }
    .one {
      background-color: red;
    }
    .one img {
      float: left;
    }


    .two {
      background-color: orange;
      overflow: auto;
    }
    .two img {
      float: right;
    }
    


    .three {
      background-color: blue;
    }
  </style>
  <body>
    <p class="one">
      <img
        src="https://www.wpbeginner.com/wp-content/uploads/2020/03/ultimate-small-business-resource-coronavirus.png"
      />
      A lot of you reading this coronavirus small business resource might be
      new to WPBeginner, and I want to welcome you to our community. My name is
      Syed Balkhi, and I created WPBeginner over 10 years ago to help small
      businesses grow and compete with the big guys in the digital world. In my
      17 year career, I have built multiple successful small businesses with
      100% remote teams. Currently, my companies have over 130+ employees,
      completely remote, all over the world. I am creating this resource because
      many of my friends, family members, WPBeginner readers, and thousands of
      fellow entrepreneurs are hurting / going through a lot of change.A lot of you reading this coronavirus small business resource might be
      new to WPBeginner, and I want to welcome you to our community. My name is
      Syed Balkhi, and I created WPBeginner over 10 years ago to help small
      businesses grow and compete with the big guys in the digital world. In my
      17 year career, I have built multiple successful small businesses with
      100% remote teams. Currently, my companies have over 130+ employees,
      completely remote, all over the world. I am creating this resource because
      many of my friends, family members, WPBeginner readers, and thousands of
      fellow entrepreneurs are hurting / going through a lot of change.
    </p>


    <p class="two">
      <img
        src="https://www.wpbeginner.com/wp-content/uploads/2020/03/ultimate-small-business-resource-coronavirus.png"
      />
      A lot of you reading this coronavirus small business resource might be
      new to WPBeginner, and I want to welcome you to our community. My name is
      Syed Balkhi, and I created WPBeginner over 10 years ago to help small
      businesses grow and compete with the big guys in the digital world. In my
      17 year career, I have built multiple successful small businesses with
      100% remote teams. Currently, my companies have over 130+ employees,
      completely remote, all over the world. I am creating this resource because
      many of my friends, family members, WPBeginner readers, and thousands of
      fellow entrepreneurs are hurting / going through a lot of change.A lot of you reading this coronavirus small business resource might be
      new to WPBeginner, and I want to welcome you to our community. My name is
      Syed Balkhi, and I created WPBeginner over 10 years ago to help small
      businesses grow and compete with the big guys in the digital world. In my
      17 year career, I have built multiple successful small businesses with
      100% remote teams. Currently, my companies have over 130+ employees,
      completely remote, all over the world. I am creating this resource because
      many of my friends, family members, WPBeginner readers, and thousands of
      fellow entrepreneurs are hurting / going through a lot of change.
    </p>


    
    <p class="three">
      <img
        src="https://www.wpbeginner.com/wp-content/uploads/2020/03/ultimate-small-business-resource-coronavirus.png"
      />
      A lot of you reading this coronavirus small business resource might be
      new to WPBeginner, and I want to welcome you to our community. My name is
      Syed Balkhi, and I created WPBeginner over 10 years ago to help small
      businesses grow and compete with the big guys in the digital world. In my
      17 year career, I have built multiple successful small businesses with
      100% remote teams. Currently, my companies have over 130+ employees,
      completely remote, all over the world. I am creating this resource because
      many of my friends, family members, WPBeginner readers, and thousands of
      fellow entrepreneurs are hurting / going through a lot of change.
    </p>
  </body>
</html>

For the element containing the float ones, use overflow:auto to completely shows its background.

Leave a Reply