0

This is a clearfix that I found on the internet. I have 3 columns and I am trying to put the clearfix after the far right column.

.right::after{
   content: " ";
   display: table;
   clear: both;
}

However it does not clear the floats... What am I doing wrong?

Nash
  • 542
  • 1
  • 7
  • 16

2 Answers2

1

you are using double ::, try using one :

.right:before,
.right:after {
    content: "";
    display: table;
    clear: both;
}

To make a clearfix work, you need to wrap your floats in a container that has the clearfix:

.clearfix:before,
.clearfix:after {
    content: "";
    display: table;
    clear: both;
}
.left {
    float: left;
}
<div class="clearfix">
    <div class="left">first</div>
    <div class="left">second</div>
    <div class="left">third</div>
</div>
abagshaw
  • 6,162
  • 4
  • 38
  • 76
Mark
  • 6,762
  • 1
  • 33
  • 50
0

Please try the following clearfix hack:

.right:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;
    }
grepsedawk
  • 3,324
  • 2
  • 26
  • 49