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 elementLorem ipsum dolor sit amet, consectetur adipiscing elit fusce.
Some other content that may or may not be important maybe haps I'm thinkin or maybe not too I dunno whatever and ever amen to that bruthah and sistah Sadie Sally sells seashells down by the seashore
clear
property
(4.3.2)
p { background-color: fuchsia; } h2 { clear: right; border: dashed 6px red; 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: 6px dashed red; background-color: fuchsia; } 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: 6px dashed red; background-color: fuchsia; 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 possibly important or maybe not well I dunno </div>
p { float: right; width: 20%; margin: 0.5em; border: 2px solid black; } div { border: 3px dotted green; overflow: hidden; }
position
property
(examples)
(4.4.2)
div#ad { position: fixed; right: 10%; top: 45%; }
property | value | description |
---|---|---|
position
|
||
static
|
default position | |
relative
|
offset from its normal static position | |
absolute
|
a fixed position within its containing element | |
fixed
|
a fixed position within the browser window | |
top ,
bottom , left ,
right
|
positions of box's corners |
#menubar { position: absolute; left: 400px; top: 50px; }
absolute
or relative
positioning)top
, bottom
, left
, right
valueswidth
property as well#area2 { position: relative; }
text-align
vertical-align
vertical-align
propertySphinx þ
property | description |
---|---|
vertical-align
|
specifies how an inline element should be positioned vertically on a line of text;
can be top , middle , bottom , baseline (default), sub , super , text-top , text-bottom , or a length value or %
|
<p style="background-color: red; padding: 0px; margin: 0px;"> <img src="images/smiley.png" alt="smile" /> </p>
padding
and margin
of 0vertical-align
to bottom
fixes the problem (so does setting line-height
to 0px
)width
, height
, min-width
, etc.) are ignored for inline boxesmargin-top
and margin-bottom
are ignored, but margin-left
and margin-right
are nottext-align
property controls horizontal position of inline boxes within it
vertical-align
property aligns it vertically within its block box
display
property
(4.4.4)
h2 { display: inline; background-color: yellow; }
property | description |
---|---|
display
|
sets the type of CSS box model an element is displayed with |
none
, inline
, block
, run-in
, compact
, ...<ul id="topmenu"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
#topmenu li { display: inline; border: 2px solid gray; margin-right: 1em; }
visibility
propertyp.secret { visibility: hidden; }
Since nobody can see this anyway: ca-ca poo-poo pee-pee!!!
property | description |
---|---|
visibility
|
sets whether an element should be shown onscreen; can be visible (default) or hidden
|
hidden
elements will still take up space onscreen, but will not be shown
display
to none
instead