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
0
votes
2 answers

applying clear-fix or micro clear-fix with just jquery

so what I'm trying to do is apply either of the clear-fix or micro clear-fix with jquery. The reason is I don't have access to the CSS so I've been using jquery to make all of my classes and other css related needs. This is really the one thing I…
loriensleafs
  • 2,205
  • 9
  • 37
  • 71
0
votes
4 answers

CSS clearfix problem with Firefox 2 and SeaMonkey

I am using yaml for layout and famous clearfix css to make sure container with floats get extended. Everything works fine with Firefox 3, IE6, IE7, IE8, Opera 9 and Google Chrome, but I have issue with Firefox 1, Firefox 2 and SeaMonkey. The…
Milan Babuškov
  • 59,775
  • 49
  • 126
  • 179
0
votes
2 answers

Footer freaking out in Chrome if I use clearfix in a div above

If I remove the clearfix div, above the footer, the text falls into place, as it does on Firefox. But that breaks other things. I don't understand how that clearfix can be affecting the footer at all though... My page:…
Kristi Simonson
  • 515
  • 1
  • 6
  • 22
0
votes
1 answer

Clearfix does not work on all pages

On my site http://jonasolaussen.se/?page_id=16 as you see the text goes under the footer, I does get better if I ad
as it does on the other sites. Does someone have an solution, i would be grateful!
0
votes
1 answer

css 960 grid clearfix not working but clear:both does work

I am using grid 960 and cannot get clearfix to work, however if I use clear:both on the element, then I can get the desired effect. I would prefer to use clearfix as I find it more reliable (usually). In the code below, the header section has a left…
0
votes
1 answer

Wordpress/Disqus visual glitch: blank space

There's a huge blank space between the WP Disqus official Plugin comments and its social bar (Like/Dislike/Settings), as shown in this screenshoot: https://i.stack.imgur.com/IodzO.jpg Coincidentally, the blank space ends where the right sidebar…
flapane
  • 543
  • 2
  • 8
  • 21
-1
votes
1 answer

Css ::after NOT displaying on same line for link text as applied using Twig

The problem: I’m trying to automate adding something to the end of the link text on a Drupal 8 site that uses twig with the ::after CSS function. Something like: &::after { content: '!!!!'; } Although the content is being outputted on the…
OMGwtfYes
  • 21
  • 2
-1
votes
1 answer

Why are the elements with .clearfix class collapsing?

Why are the elements with the class .clearfix still collapsing and they have no height. the clearfix should solve it i thought. the class .clearfix is found under /GENERELLES/ i tried everything but i cant solve this problem. the problem is that the…
No Body
  • 3
  • 4
-1
votes
1 answer

Header stuck in nav bar.Where I need to put clearfix?

When I added background image in .header the image stuck inside the navbar.Notice that comes before in HTML.I don't know where should I use clearfix or maybe it is not the problem.
Breik
  • 1
-1
votes
1 answer

Outer div won't expand when slide-in menu height changes

Can anyone help me out with this? I've tried clear fix and a number of other things but cannot figure out why the container column (center one) which contains the slide-in navigation menu won't auto adjust its height. Code pen of non working code…
Gerd
  • 89
  • 4
-1
votes
2 answers

Where to use clear fix in html inside of a thumbnail dynamic gallery

I have a dynamic gallery, where its looping. but my gallery thumbs are messed up. I used clearfix and it worked,but i press ctrl z and it didnt work ctrl y. So i lost where it was my mistake with clear fix. So now my row is not going by side i…
James Allan
  • 280
  • 5
  • 18
-1
votes
1 answer

clearing without a wrapping 'row' container

Is there a way to clear after the last element of a row without a wrapping container per row? The column sizes inside will vary, there is a 'last' class, can I clear after that div is closed? I can't add anything to the markup. Markup:
sarah3585
  • 637
  • 13
  • 37
-1
votes
1 answer

Why
didn't used?

Hi, sometimes learning something makes you more confused, I am in that position right now, thanks in advance. I asked a question in this address: Why
used? After getting the answer and accepting (I also read the links given…
Andre Chenier
  • 1,166
  • 2
  • 18
  • 37
-1
votes
2 answers

CSS - Clear fix isn't working

I'm applying clear fix to the parent (ul) but it's not working When set display:block; to the a, then the clear fix works, but why? The code in here HTML
-1
votes
2 answers

Having Issue with Clearfix Class

Can you please take a look my webpage(contact page) and let me know why still I am having this issue whit clearfix class? I even used the clear both on all elements but still this is happening! and tghe #bizleft and #bizright are not…
user1986096
  • 363
  • 1
  • 3
  • 7
1 2 3
15
16