background preloader


Facebook Twitter

Better float containment in IE using CSS expressions. Research into improving the cross-browser consistency of both the “clearfix” and “overflow:hidden” methods of containing floats.

Better float containment in IE using CSS expressions

The aim is to work around several bugs in IE6 and IE7. This article introduces a new hack (with caveats) that can benefit the “clearfix” methods and the new block formatting context (NBFC) methods (e.g. using overflow:hidden) of containing floats. It’s one outcome of a collaboration between Nicolas Gallagher (that’s me) and Jonathan Neal. Clearfix Reloaded + overflow:hidden Demystified. Clearfix and overflow:hidden may be the two most popular techniques to clear floats without structural markup.

clearfix Reloaded + overflow:hidden Demystified

This short article is about enhancing the first method and shedding some light on the real meaning of the second. clearfix In everything you know about clearfix is wrong I explain the issues this method creates across browsers and I suggest to only use clearfix on elements that are not next to floats (e.g. a modal window), although as authors we still have to deal with collapsing margins. This demo page demonstrates the issue. A new micro clearfix hack.

The clearfix hack is a popular way to contain floats without resorting to using presentational markup.

A new micro clearfix hack

This article presents an update to the clearfix method that further reduces the amount of CSS required. Demo: Micro clearfix hack Known support: Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+ The “micro clearfix” method is suitable for modern browsers and builds upon Thierry Koblentz’s “clearfix reloaded”, which introduced the use of both the :before and :after pseudo-elements. Here is the updated code (I’ve used a shorter class name too): This “micro clearfix” generates pseudo-elements and sets their display to table. Html - What is a clearfix? The Clearfix: Force an Element To Self-Clear its Children. This will do you fine these days (IE 8 and up): Apply it to any parent element in which you need to clear the floats.

The Clearfix: Force an Element To Self-Clear its Children

For example: You would use this instead of clearing the float with something like <br style="clear: both;" /> at the bottom of the parent (easy to forget, not handleable right in CSS, non-semantic) or using something like overflow: hidden; on the parent (you don't always want to hide overflow). All About Floats. By Chris Coyier On What is "Float"?

All About Floats

Float is a CSS positioning property. To understand its purpose and origin, we can look to print design. In a print layout, images may be set into the page such that text wraps around them as needed. This is commonly and appropriately called "text wrap". In page layout programs, the boxes that hold the text can be told to honor the text wrap, or to ignore it. In web design, page elements with the CSS float property applied to them are just like the images in the print layout where the text flows around them. Initiation au positionnement CSS : 2.position float.

La position float retire une boîte du flux normal pour la placer le plus à droite ou le plus gauche possible dans son conteneur.

Initiation au positionnement CSS : 2.position float

Comment fonctionne CSS Float. On n'utilise plus autant les float aujourd'hui, mais parfois c'est encore incontournable.

Comment fonctionne CSS Float

Dans cette excellente intro (ou révision), Ire Aderinokun revisite float en présentant les règles qui régissent son comportement. Par Ire Aderinokun Même si je n’utilise plus que rarement les float aujourd’hui, il y a encore des circonstances où ils constituent la seule solution viable. Dans ces rares occasions, je suis souvent contrariée parce qu’ils ne fonctionnent pas comme je l’avais prévu. J’ai donc décidé d’aller voir de plus près les règles qui régissent le comportement des float et la façon correcte de les utiliser. Inline-block est-il un substitut aux floats ? Par Steven Bradley Quand vient le moment de développer la mise en page avec CSS, float fait le plus gros du travail.

Inline-block est-il un substitut aux floats ?

All About Floats. Clearing a float container without source markup. (This clearing technique was developed by Tony Aslett, of

Clearing a float container without source markup

The earliest known mention of the basic :after idea is found here.) Notice as of March 4th, 2008: The article you are reading is getting a bit old and much new information on the subject of clearing has appeared since it was written. You may find this newer article very interesting. CSS - Clearing floats. Page last changed today A common problem with float-based layouts is that the floats' container doesn't want to stretch up to accomodate the floats.

CSS - Clearing floats

If you want to add, say, a border around all floats (ie. a border around the container) you'll have to command the browsers somehow to stretch up the container all the way. Let's try it. This is the CSS we'll use throughout the page: Now this happens: The left column. The right column. We want the black border to go around both our floating columns. Empêcher les flottants de dépasser de leur conteneur.

Par défaut dans les navigateurs, les éléments positionnés grâce à la propriété CSS float (aussi appelés flottants, ou en anglais floats) sortent du flux de leur conteneur. Autrement dit, les flottants «dépassent». C'est ainsi qu'on se retrouve avec des conteneurs qui font zéro pixel de hauteur, des colonnes qui passent à travers un pied de page, et autres résultats peu souhaitables. Contained Floats, the clearfix technique. Author: Tony Aslett First created 8-May-2004 There is a large and growing movement by web developers and designers towards web standards.

Part of that movement focuses on clean mark-up, which has many long term benefits such as easier maintenance, lighter pages and better support by browsers of the future. One thing that has bugged me was the need to add clearing elements to the mark-up to keep a container wrapped around a floated element. Most people use a division, horizontal rule or a break and set it to clear both to keep the container around the float. Well now there's another way that will free us from the need to add extra clearing elements.

Firstly, if you don't have a good understanding of floats here's a couple of articles you should read. for it was these very articles that led me to this solution. Matt Brubeck described how you could use the pseudo element :after on the container of the float. Clearing a float container without source markup.