Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replace the clear:both with pseudo class

Tags:

html

css

block

Previously, when I had floatings blocks, and i will stop the float, i used ;

<div style="clear:both"></div>

But now, i'm solve this problem with pseudo class :

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

I has always works perfectly. But today... It doesn't work... ! Look at this clear example : http://jsfiddle.net/YsueS/2/

I know my problem is a total beginner problem. I have sold this problem so many times... I really don't understand why it doesn't work here !

Many thanks all of you !

like image 585
Damien Avatar asked Oct 31 '13 19:10

Damien


1 Answers

Sure - you could clear it via an :after clearfix, however the most optimal, lightweight solution would just be to set overflow:hidden on the parent, achiving the desired effect with much less coding.

#mention {
    overflow: hidden;
}

jsFiddle here

To answer the question directly though, you should have applied the :after clearfix to #mentions - the parent, instead of the child.. jsFiddle here it works.

like image 147
Josh Crozier Avatar answered Sep 28 '22 11:09

Josh Crozier