30

Vertua CSS Problems

Embed Size (px)

Citation preview

Page 1: Vertua CSS Problems
Page 2: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

The Question

“”

Trying to move toward absolute positioning versus floats for layout.... I am trying to figure out if [you] have to always use a height

on the wrapper div. If I have text columns that have no specific

height it seems everything breaks at that point.

Shane Perran, graphicalwonder.com

Page 3: Vertua CSS Problems
Page 4: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Absolute Positioning

❖ It’s all about the x and the y (axes, that is)

❖ Treating parts of your document as distinct “layers”

❖ Use CSS to precisely place them upon a coordinate grid

Cake, yes? Let’s look at an example.

Page 5: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

A new “positioning context”

div.photo { position: relative;}

p.caption { position: absolute; bottom: 9px;}

<div class="photo"> <p>Here’s a caption. Yay.</p> <img src="photo.jpg" alt="" /></div>

Page 6: Vertua CSS Problems

"Bottom-blindness"

Page 8: Vertua CSS Problems

position: relative;

Page 9: Vertua CSS Problems

position: absolute;width: [x];

position: absolute;width: [y]

margin-left: [x];margin-right: [y];

Page 10: Vertua CSS Problems
Page 11: Vertua CSS Problems
Page 12: Vertua CSS Problems
Page 13: Vertua CSS Problems
Page 14: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Remember <img align="left">?

Page 15: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

The basics

img { float: left; }

Page 16: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

The basics

img { float: right; }

Page 17: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Reflow, floats, and you

img { float: left; }

Page 18: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Restoring order to the flow

p.clear { clear: left; }

Page 20: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Okay, great. Kitty pictures. So?

❖ Floats can provide us with a more flexible layout model

❖ Clearing allows the components of our designs to become “context aware”

❖ Let’s view a simple example.

Page 21: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Marrying floats and positioning

Page 22: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

The marvelous markup

<div class="person"> <div class="image"> <img src="photo.jpg" alt="" /> </div> <dl> <dt><a href="#">Durstan who?</a></dt> <dd> <ul>...</ul> </dd> </dl></div>

Page 23: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Getting our 2-column structure

Page 24: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

Getting our 2-column structure

.person { clear: left;}

.person .image { float: left;}

Page 25: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

One minor addition

<div class="person"> <div class="image"> <img src="photo.jpg" alt="" /> </div> <dl> <dt><a href="#">Durstan who?</a></dt> <dd> <ul>...</ul> </dd> </dl></div>

Page 26: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

One minor addition

<div class="person"> <div class="image"> <img src="photo.jpg" alt="" /> </div> <dl> <dt><a href="#"><i></i>Durstan who?</a></dt> <dd> <ul>...</ul> </dd> </dl></div>

Page 27: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

.person { position: relative;}

Layering the link

position: relative;

Page 28: Vertua CSS Problems

ethan marcottESXSW2006www.vertua.com

.person dt i { display: block; height: 160px; width: 160px; position: absolute; left: 0; top: 0;}

.person { position: relative;}

Layering the link

<i></i>