| Start |
|---|
| Float an Image Within Text The most basic use of a float is having text wrap around an image. The below code will produce two paragraphs and an image, with the second paragraph flowing around the image. Notice that it is always content after the floated element that flows around the floated element. HTML: CSS: This will be the output
|
| clear property The clear property is directly related to floats. Property Values:
|
| Clearfix The clearfix hack is a popular way to contain floats (N. Gallagher aka @necolas) Not to be confused with the 3 versions with slightly different effects (sources :A new micro clearfix hack (opens new window) by N. Gallagher and clearfix reloaded (opens new window) by T. J. Koblentz): Clearfix (with top margin collapsing of contained floats still occurring)Clearfix also preventing top margin collapsing of contained floatsClearfix with support of outdated browsers IE6 and IE7Codepen showing clearfix effect (opens new window) Other resource: Everything you know about clearfix is wrong (opens new window) (clearfix and BFC - Block Formatting Context while hasLayout relates to outdated browsers IE6 maybe 7) |
| In-line DIV using float The The output of the following code will be
We can make them in-line by adding a HTML: CSS |
| Simple Two Fixed-Width Column Layout A simple two-column layout consists of two fixed-width, floated elements. Note that the sidebar and content area are not the same height in this example. This is one of the tricky parts with multi-column layouts using floats, and requires workarounds to make multiple columns appear to be the same height. HTML: CSS: |
| Simple Three Fixed-Width Column Layout HTML: CSS: |
| Two-Column Lazy/Greedy Layout This layout uses one floated column to create a two-column layout with no defined widths. In this example the left sidebar is "lazy," in that it only takes up as much space as it needs. Another way to say this is that the left sidebar is "shrink-wrapped." The right content column is "greedy," in that it takes up all the remaining space. HTML: CSS: |
| Use of overflow property to clear floats Setting Note: using Syntax
RemarksAs float implies the use of the block layout, it modifies the computed value of the display values in some cases [1] [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/float (opens new window) MDN |
Read Article
https://develop.horje.com/learn/1434/reference