Except where otherwise noted, the contents of this presentation are Copyright 2010 Marty Stepp and Jessica Miller.
float
property
(reference)
(4.3.1)
property | description |
---|---|
float
|
side to hover on; can be left , right , or none (default)
|
<img src="images/borat.jpg" alt="Borat" class="headericon" /> Borat Sagdiyev (born July 30, 1972) is a ...
img.headericon { float: left; }
div
s from being aligned to floated...
float
ing content and widthI am not floating, no width set
I am floating right, no width set
I am floating right, no width set, but my text is very long so this paragraph doesn't really seem like it's floating at all, darn
I am not floating, 45% width
I am floating right, 45% width
width
property value
width
is specified, other content may be unable to wrap around the floating elementclear
property
(4.3.2)
p { background-color: fuchsia; } h2 { clear: right; background-color: yellow; }
Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with ...
property | description |
---|---|
clear
|
disallows floating elements from overlapping this element; can be left , right , both , or none (default)
|
div#sidebar { float: right; } p { clear: right; }
<p><img src="images/homestar_runner.png" alt="homestar runner" /> Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with ....</p>
p { border: 2px dashed black; } img { float: right; }
p
containing the image to extend downward so that its border encloses the entire image
overflow
property
(4.3.3)
p { border: 2px dashed black; overflow: hidden; }
Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with ....
property | description |
---|---|
overflow
|
specifies what to do if an element's content is too large; can be auto , visible , hidden , or scroll
|
<div> <p>the first paragraph</p> <p>the second paragraph</p> <p>the third paragraph</p> Some other text that is important </div>
p { float: right; width: 20%; margin: 0.5em; border: 2px solid black; } div { border: 3px dotted green; overflow: hidden; }