Title: YUIs CSS Foundation
1YUIs CSS Foundation
- Nate Koechley
- 25 Oct 2007, Yahoo!
- natek_at_yahoo-inc.com
2Welcome.
3(No Transcript)
4Yahoo! User Interface (YUI)
- Documentation
- developer.yahoo.com/yui
- Mailing list
- groups.yahoo.com/group/ydn-javascript
- Blog
- yuiblog.com
- Nate Koechley
- natek_at_yahoo-inc.com
5The User Interface
CSS
JavaScript
6The User Interface
CSS
JavaScript
7CSS is different.Property values from anywhere
and everywhere mingle and conflate before a final
value is calculated.
8Powerful but risky.Enables elegance.But a bit
brittle.
9CSS is accretive.
Computed Style
Rule 2
10Two primary layering models
- The Cascade model
- Rules are sorted according to weight and origin.
- The Inheritance model
- Some properties are passed to descendent nodes,
some of which can accept them. - (Tricky when values repeat, like "80")
11The Cascade
Rule 1
Computed Style
Rule 2
12Inheritance
Parent node
Child node
Grandchild
Rule 1
13Errors and discrepancies are transferred equally
efficiently.
14Goals of YUI CSS
- Provide stability
- Normalize differences
- Solve recurring problems
- Centrally manage complexity
15YUI CSS Components
- Reset a clean foundation
- Fonts typographical control
- Grids layout and page control
- Base basic helper/snippets lib
16"Base" is an outsider
- Foundation
- Reset
- Fonts
- Grids
17 18Including YUI CSS
- Recommended
- Use ltlinkgt
- Use http//yui.yahooapis.com
- Concatenate with your own CSS
- More info
- http//developer.yahoo.com/performance/
19Including Reset.css
- href"
- http//yui.yahooapis.com/
- 2.3.1/
- build/
- reset/reset-min.css"
20Including Fonts.css
- href" http//yui.yahooapis.com/
- 2.3.1/
- build/
- fonts/fonts-min.css"
21Including Grids.css
- href" http//yui.yahooapis.com/
- 2.3.1/
- build/
- grids/grids-min.css"
22Pre-Concatenated Version
- href" http//yui.yahooapis.com/
- 2.3.1/
- build/
- reset-fonts-grids/
- reset-fonts-grids.css"
-
- (concatenated files are "min" by definition)
23Using YUI Grids
- Control overall page width and centering.
- Six preset templates accommodate all IAB ad unit
sizes nearly all Y! pages. - Easily create nested multi-column regions.
244kb
25A black box system.
26Using YUI Grids
- Control overall page width and centering.
- Six preset templates accommodate all IAB ad unit
sizes nearly all Y! pages. - Easily create nested multi-column regions.
27Part I Overall Page Width
- 750px centered
- 950px centered
- 974px centered
- 100 fluid
- (easy to customize, but that should be rare.)
28750px, centered
29750px, centered
30750px, centered
31950px, centered
32950px, centered
33974px, centered
34974px, centered
35974px, centered
36100 fluid
37100 fluid
38Control the page from the root node.
39The root node
- ltbodygt
- ltdivgtlt/divgt
- lt/bodygt
40Why a div? Isnt that "divitis?"
41What are DIVs for?
- "The DIV element, in conjunction with id and
class attributes, offers a generic mechanism for
adding structure to documents."
42The root node
- ltbodygt
- ltdivgtlt/divgt
- lt/bodygt
43Available ID values
- 750px centered doc
- 950px centered doc2
- 974px centered doc4
- 100 fluid doc3
44750px centered document
- ltbodygt
- ltdiv id"doc"gtlt/divgt
- lt/bodygt
45950px centered document
- ltbodygt
- ltdiv id"doc2"gtlt/divgt
- lt/bodygt
46974px centered document
- ltbodygt
- ltdiv id"doc4"gtlt/divgt
- lt/bodygt
47100 fluid document
- ltbodygt
- ltdiv id"doc3"gtlt/divgt
- lt/bodygt
48Notes
- Page widths are defined with EMs. This means the
page will expand when users zoom this fonts. - Its easy to lock it down if you must.
49Locking the page width
- Fluid by default
- doc2
- width73.074emwidth71.313em
-
- Easy to lock with local override
- doc2
- width950px
50Notes
- Page widths are defined with EMs. This means the
page will expand when users zoom this fonts. Its
easy to lock it down if you must. - The divdoc can hold anything.
51doc can hold anything
- ltbodygt
- ltdiv id"doc"gt
- ltdiv id"hd"gtlt/divgt
- ltdiv id"bd"gtlt/divgt
- ltdiv id"ft"gtlt/divgt
- lt/divgt
- lt/bodygt
52Notes
- Page widths are defined with EMs. This means the
page will expand when users zoom this fonts. Its
easy to lock it down if you must. - The divdoc can hold anything.
- Centering isamazinglystill non-trivial across
the range of A-Grade browsers.
53(A quick aside about Graded Browser Support.)
54Graded Browser Support
- Whitelist of browsers that enjoy A-Grade support
from YUI Yahoo!
http//developer.yahoo.com/yui/articles/gbs
55(OK, now back to Grids.)
56Using YUI Grids
- Control overall page width and centering.
- Six preset templates accommodate all IAB ad unit
sizes and the vast majority of Y! pages. - Easily create nested multi-column regions.
57(No Transcript)
58(No Transcript)
59The narrow column is fixed width. The main
column gets the rest.The size of their parent
is irrelevant.
60Template 1 160px left
61Template 2 180px left
62Template 3 300px left
63Template 4 180px right
64Template 5 240px right
65Template 6 300px right
66(No Transcript)
67(No Transcript)
682 columns 2 content blocks
69Two content blocks
- ltdiv id"doc"gt
- ltdiv class"yui-b"gtlt/divgt
- ltdiv class"yui-b"gtlt/divgt
- lt/divgt
70Now, identify the main block.
71identify the main block
- ltdiv id"doc"gt
- ltdiv id"yui-main"gt
- ltdiv class"yui-b"gtlt/divgt
- lt/divgt
- ltdiv class"yui-b"gtlt/divgt
- lt/divgt
72Now, choose a template class.
73Available Template Classes
- left 160px .yui-t1
- left 180px .yui-t2
- left 300px .yui-t3
- right 180px .yui-t4
- right 240px .yui-t5
- right 300px .yui-t6
74Set the templateon the root DIV.
75Set the template at the root
- ltdiv id"doc" class"yui-t3"gt
- ltdiv id"yui-main"gt
- ltdiv class"yui-b"gtlt/divgt
- lt/divgt
- ltdiv class"yui-b"gtlt/divgt
- lt/divgt
76Hidden featureSource order independence.
77Source order Independence
- The order of the blocks does not impact the
layout. - Put important content first to boost
Accessibility, Usability, and SEO
78Using YUI Grids
- Control overall page width and centering.
- Six preset templates accommodate all IAB ad unit
sizes nearly all Y! pages. - Easily create nested multi-column regions.
79Nested Grids
- Use nested grids when you need divisions of space
beyond templates. - Nested grids are based on a simple markup
microformat.
80The basic microformat
- Grid holder .yui-g
- Units .yui-u
- ltdiv class"yui-g"gt
- ltdiv class"yui-u"gtlt/divgt
- ltdiv class"yui-u"gtlt/divgt
- lt/divgt
81Each unit takes up half.(half of anything -
doesnt care)
.yui-u
.yui-u
82One more step .first
- Grid holder .yui-g
- Units .yui-u
- First unit .first
- ltdiv class"yui-g"gt
- ltdiv class"yui-u first"gtlt/divgt
- ltdiv class"yui-u"gtlt/divgt
- lt/divgt
83Each unit takes up half.Gutters are voids
between them.
.yui-u .first
.yui-u
84What about four (22)?
85Nest again for four columns
- div.yui-g
- div.yui-g.first
- div.yui-u.first /div
- div.yui-u /div
- /div
- div.yui-g
- div.yui-u.first /div
- div.yui-u /div
- /div
- /div
86What about three columns? What about uneven
distributions?
87Special Grid Holders
- For three columns
- .yui-gb 1/3 -- 1/3 -- 1/3
- For uneven distributions
- .yui-gc 2/3 -- 1/2
- .yui-gd 1/3 -- 2/3
- .yui-ge 3/4 -- 1/4
- .yui-gf 1/4 -- 3/4
88Uneven columns (for example 1/32/3)
- div.yui-gd
- div.yui-u.first /div
- div.yui-u /div
- /div
.yui-gd
.yui-u.first
.yui-u
89Divide into three
- div.yui-gb
- div.yui-u.first /div
- div.yui-u /div
- div.yui-u /div
- /div
.yui-gb
.yui-u.first
.yui-u
.yui-u
90Grids are Stackable
.yui-gd
.yui-u.first
.yui-um
.yui-gb
.yui-u.first
.yui-u
.yui-u
91Nested Grids
1
1/3
1/3
1/3
1
1/3
1/3
1/3
92Lets review
- Page Width divdoc
- Templates .yui-t1
- Grids .yui-g .yui-u
- Fills any space.
- Nestable stackable.
- Sweet! You can now make intricate layouts safely
and quickly.
93(No Transcript)
94Using YUI Fonts
- Mostly automatic.
- Reliably set font sizes.
- Other niceties.
95For free
- Arial (and fallbacks)
- 13px font size
- 16px line height
96Using YUI Fonts
- Mostly automatic.
- Reliably set precise font sizes.
97Use Percentages ()
- 10px 77
- 11px 85
- 12px 93
- 13px 100
- 14px 108
- 15px 116
- 16px 123.1
98Dont use pixels
- Pixel sizes break IEs ability to zoom fonts.
Always use percentages
h1 font-size123.1 .hd h1 font-size77
99Using YUI Fonts
- Mostly automatic.
- Reliably set precise font sizes.
- Other niceties.
100Allows User Zooming
- Yes.
- Fonts and Grids combine to preserve user zooming.
Delivers OS-appropriate Fonts
Yes. Happens for free.
101Fonts Tip
- Avoid using the font shorthand because it is
parsed inconsistently across browsers.
102Using YUI Reset
- Lowest-level piece of YUI CSS
- Creates a clean and sturdy foundation.
103Quiz
- What is the default visualization of the STRONG
element? - Of the UL LI element?
104AnswerHTML has no visualization.
105Where does it come from?
- Browsers contains a browser.css file.
- Fine, but theyre all different.
- Reset.css removes everything.
106What does Reset do?
- Sets margin and padding to zero
- Sets borders to zero
- Removes visual list style (ol, ul, dl)
- Sets fonts to 100 of base
- Sets font-weight font-style to normal
- Etc
107Using Reset
- Nothing to learn, but youll need to be explicit.
- Browsers are good at guessing, but even better at
following directions. - Its a good reminder that HTML should be chosen
based on content alone.
108Using YUI Base
- Almost a "snippets" library.
- Gives back what Reset removes.
- Great for linear HTML content pages.
109A page with Grids Base
110YUI CSS Summary
- Reset a clean foundation
- Fonts typographical control
- Grids layout and page control
- Base basic helper/snippets lib
111Other YUI CSS Notes
- Calculating EMs
- Customizing Template Presets
112Calculating EMs
- Pixel width / 13px EM width
- EM width x 0.9759 IEs EM width
- custom-doc
- width46.15em/ non-IE
- width45.04em/ IE /
113Customizing Templates
- .yui-t2 .yui-b
- floatleft
- width13.8456em
- width13.512em
-
- .yui-t2 yui-main .yui-b
- margin-left14.8456em
- margin-left14.512em
-
114Thank you.
115More Information
- Documentation
- http//developer.yahoo.com/yui
- Mailing list
- http//groups.yahoo.com/group/ydn-javascript
- Blog
- http//yuiblog.com
- Nate Koechley
- natek_at_yahoo-inc.com
116CC Image Credits
- Pyramide Inversée http//www.flickr.com/photos/dr
odriguez/117818017/ - Cusco Qoricancha Inca foundations
- http//www.flickr.com/photos/yandi/364125159/
- Three-legged Stool
- http//www.mnartists.org/work.do?rid34382
- Enjoy the openness
- http//www.flickr.com/photos/perfhex/293118214/
- Night Lights
- http//www.flickr.com/photos/fornal/391746944/
- Helvetica
- http//www.flickr.com/photos/redsil/490734685/