Questions tagged [clearfix]

A clearfix is a way for an element to automatically clear after itself, so that you don't need to add additional markup. It's generally used in float layouts where elements are floated to be stacked horizontally.

Description

A clearfix is a way for an element to automatically clear after itself, so that you don't need to add additional markup. It's generally used in float layouts where elements are floated to be stacked horizontally.

The clearfix is a way to combat the zero-height container problem for floated elements.


Examples

.clearfix:after {
    content: " ";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

Normally you would need to do something as follows:

<div style="float: left;">Sidebar</div>
<div style="clear: both;"></div> <!-- Clear the float -->

With clearfix, you only need to

<div style="float: left;" class="clearfix">Sidebar</div>
<!-- No Clearing div! -->

References

  1. StackOverflow - What is clearfix?
  2. Article by Chris Coyer @ CSS-Tricks
  3. A new micro clearfix hack
  4. An Overview of Different clearfix Methods
230 questions
-2
votes
1 answer

responsive image with text on the right using clearfix

I'm trying to create a responsive image at the right of the page (from top to bottom) and trying to put text at the right of the image in the space that is leftover but it doens't seem to work. I've googled and found a solution called clearfix. It…
Lance
  • 1
  • 2
-2
votes
1 answer

Wordpress Plugin not Work & Display on Particular Post

I am here for some help regarding wordpress theme or plugin issue. My Website Url : http://www.jhakaas.net The post which has content the plugin works properly [http://jhakaas.net/bicycle-photo-gallery/] but the plugin does not work in the post…
-2
votes
2 answers

block-style navigation css ribbon only shows one side

I am trying to create css ribbons for a block-style main navigation, but the right-hand side triangles of the ribbon don't work when I include "display:table;" or "display:block;" in Clearfix. Naturally, when I remove Clearfix, the ribbon works…
LLO
  • 1
  • 2
-3
votes
1 answer

Understand bootstrap 'clearfix'

I do not understand how to use clearfix. I have this bootply as an example. There's a Bootstrap carousel and, next section, is not appearing right below it. I assume this is floating problem but I don't know how to solve it. Can anyone explain it…
markens
  • 113
  • 6
-6
votes
3 answers

i need an answer please : bootstrap 3 this is for a job applyment?

In order to get a job , the recruitement ask me to solve this problem in order to get the job ! Here the html of the question :
ls.94
  • 17
  • 3
1 2 3
15
16