|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>CSS Fonts</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
<a href="#toc" class="jump">Jump to Table of Contents</a> |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
<h1>CSS Fonts</h1> |
|
|
27 |
<div class="yui3-g"> |
|
|
28 |
<div class="yui3-u-3-4"> |
|
|
29 |
<div id="main"> |
|
|
30 |
<div class="content"> <div class="intro"> |
|
|
31 |
<p class="deprecated"><em> |
|
|
32 |
<strong>Note:</strong> The files "fonts.css" and "fonts-context.css" are deprecated, use "cssfonts.css" and |
|
|
33 |
"cssfonts-context.css" instead.</em></p> |
|
|
34 |
|
|
|
35 |
<p>The foundational CSS Fonts provides cross-browser typographical normalization and control while still allowing users to choose and adjust their font size. Both Standards and Quirks modes are supported in A-grade browsers.</p> |
|
|
36 |
|
|
|
37 |
<p><strong>Note:</strong> <a href="../cssbase/">CSS Base</a> can complement <a href="../cssreset/">CSS Reset</a> by applying a style foundation for common HTML elements that is consistent for <a href="http://developer.yahoo.com/yui/3/articles/gbs">A-grade browsers</a>.</p> |
|
|
38 |
</div> |
|
|
39 |
|
|
|
40 |
<h2 id="start">Getting Started</h2> |
|
|
41 |
|
|
|
42 |
<h3 id="dependencies">Include Dependencies</h3> |
|
|
43 |
|
|
|
44 |
<p>To use CSS Fonts, include the following source file in your web page with the link element:</p> |
|
|
45 |
|
|
|
46 |
<pre class="code prettyprint"><link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.10.3/build/cssfonts/cssfonts-min.css"></pre> |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
<h3 id="context">Global vs. Contextual</h3> |
|
|
50 |
|
|
|
51 |
<p>YUI's CSS resources apply rules to HTML elements directly (using <a href="http://www.w3.org/TR/CSS21/selector.html#type-selectors">type selectors</a>). An alternate version of the resource is available that target elements by context only. This contextual <code>-context.css</code> version selects HTML elements only when they descend from the <code>.yui3-cssfonts</code> classname.</p> |
|
|
52 |
|
|
|
53 |
<p>Here is how to include the contextual version of CSS Fonts:</p> |
|
|
54 |
|
|
|
55 |
<pre class="code prettyprint"><!-- Source File --> |
|
|
56 |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.10.3/build/cssfonts/cssfonts-context-min.css"></pre> |
|
|
57 |
|
|
|
58 |
<h2 id="using">Using CSS Fonts</h2> |
|
|
59 |
|
|
|
60 |
<h3 id="default">Default Text</h3> |
|
|
61 |
|
|
|
62 |
<p>With the CSS linked into the page, all text renders in the Arial font, at 13 pixel size, with 16 pixel line-height. The <code>pre</code> and <code>code</code> elements use the "monospace" font-family. <a href="cssfonts-basic.html">Here's an example of HTML elements after Fonts has been applied</a>.</p> |
|
|
63 |
|
|
|
64 |
<h3 id="fontsize">Font-size Adjustment</h3> |
|
|
65 |
|
|
|
66 |
<p>To change the size of a font, always use percentages as the units because they render more consistently than ems, and because they allow user-initiated resizing (unlike pixels). <a href="cssfonts-size.html">See the example</a>.</p> |
|
|
67 |
|
|
|
68 |
<pre class="code prettyprint">#demo1 {font-size:85%;} /*renders 11px */ |
|
|
69 |
#demo2 {font-size:100%;} /*renders 13px */ |
|
|
70 |
#demo3 {font-size:108%;} /*renders 14px */ |
|
|
71 |
#demo4 {font-size:123.1%;} /*renders 16px */ |
|
|
72 |
#demo5 {font-size:138.5%;} /*renders 18px */</pre> |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
<div id="fontsize-chart"> |
|
|
76 |
<table border="1" cellpadding="3" cellspacing="3" class="auto"> |
|
|
77 |
<tr> |
|
|
78 |
<th class="first-col">For pixels (px)</th> |
|
|
79 |
<th>Declare this percent (%)</th> |
|
|
80 |
</tr> |
|
|
81 |
<tr class="odd"><td class="first-col"> 10 </td><td> 77</td></tr> |
|
|
82 |
<tr class="even"><td class="first-col"> 11 </td><td> 85 </td></tr> |
|
|
83 |
<tr class="odd"><td class="first-col"> 12 </td><td> 93 </td></tr> |
|
|
84 |
<tr class="even"><td class="first-col"> 13 </td><td> 100 </td></tr> |
|
|
85 |
<tr class="odd"><td class="first-col"> 14 </td><td> 108 </td></tr> |
|
|
86 |
<tr class="even"><td class="first-col"> 15 </td><td> 116 </td></tr> |
|
|
87 |
<tr class="odd"><td class="first-col"> 16 </td><td> 123.1 </td></tr> |
|
|
88 |
<tr class="even"><td class="first-col"> 17 </td><td> 131 </td></tr> |
|
|
89 |
<tr class="odd"><td class="first-col"> 18 </td><td> 138.5 </td></tr> |
|
|
90 |
<tr class="even"><td class="first-col"> 19 </td><td> 146.5 </td></tr> |
|
|
91 |
<tr class="odd"><td class="first-col"> 20 </td><td> 153.9 </td></tr> |
|
|
92 |
<tr class="even"><td class="first-col"> 21 </td><td> 161.6 </td></tr> |
|
|
93 |
<tr class="odd"><td class="first-col"> 22 </td><td> 167 </td></tr> |
|
|
94 |
<tr class="even"><td class="first-col"> 23 </td><td> 174 </td></tr> |
|
|
95 |
<tr class="odd"><td class="first-col"> 24 </td><td> 182 </td></tr> |
|
|
96 |
<tr class="even"><td class="first-col"> 25 </td><td> 189 </td></tr> |
|
|
97 |
<tr class="odd"><td class="first-col"> 26 </td><td> 197 </td></tr> |
|
|
98 |
</table> |
|
|
99 |
</div> |
|
|
100 |
|
|
|
101 |
<h2 id="family">Font-family Adjustment</h2> |
|
|
102 |
<p>Arial is the default font-family for all text (except <code>pre</code> and <code>code</code>) when you use Fonts CSS. Specify a new font-family when you want something other than Arial.</p> |
|
|
103 |
|
|
|
104 |
<pre class="code prettyprint">#demo1 {} |
|
|
105 |
#demo2 {font-family:monospace;} |
|
|
106 |
#demo3 {font-family:georgia;} |
|
|
107 |
#demo4 {font-family:verdana;} |
|
|
108 |
#demo5 {font-family:times;}</pre> |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
<h3 id="start-contextually">Using CSS Fonts In Specific Contexts</h3> |
|
|
112 |
|
|
|
113 |
<p>If you're using the contextual version, CSS Fonts's rules are only applied to elements that descend from a node with a class value of <code>.yui3-cssfonts</code>. The classname can go as high in the DOM tree as desired, including on the <code><html></code> element directly.</p> |
|
|
114 |
|
|
|
115 |
<p>The following code snippet show how you might apply CSS Fonts to one of two columns:</p> |
|
|
116 |
|
|
|
117 |
<pre class="code prettyprint"><div> |
|
|
118 |
<div class="yui3-cssfonts"><h1>Lorem Ipsum</h1></div> |
|
|
119 |
<div><h1>Lorem Ipsum</h1></div> |
|
|
120 |
</div></pre> |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
<p>Here is an example showing how to <a href="cssfonts-context.html">apply CSS Fonts to a subset of a page</a>.</p> |
|
|
124 |
</div> |
|
|
125 |
</div> |
|
|
126 |
</div> |
|
|
127 |
|
|
|
128 |
<div class="yui3-u-1-4"> |
|
|
129 |
<div class="sidebar"> |
|
|
130 |
|
|
|
131 |
<div id="toc" class="sidebox"> |
|
|
132 |
<div class="hd"> |
|
|
133 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
134 |
</div> |
|
|
135 |
|
|
|
136 |
<div class="bd"> |
|
|
137 |
<ul class="toc"> |
|
|
138 |
<li> |
|
|
139 |
<a href="#start">Getting Started</a> |
|
|
140 |
<ul class="toc"> |
|
|
141 |
<li> |
|
|
142 |
<a href="#dependencies">Include Dependencies</a> |
|
|
143 |
</li> |
|
|
144 |
<li> |
|
|
145 |
<a href="#context">Global vs. Contextual</a> |
|
|
146 |
</li> |
|
|
147 |
</ul> |
|
|
148 |
</li> |
|
|
149 |
<li> |
|
|
150 |
<a href="#using">Using CSS Fonts</a> |
|
|
151 |
<ul class="toc"> |
|
|
152 |
<li> |
|
|
153 |
<a href="#default">Default Text</a> |
|
|
154 |
</li> |
|
|
155 |
<li> |
|
|
156 |
<a href="#fontsize">Font-size Adjustment</a> |
|
|
157 |
</li> |
|
|
158 |
</ul> |
|
|
159 |
</li> |
|
|
160 |
<li> |
|
|
161 |
<a href="#family">Font-family Adjustment</a> |
|
|
162 |
<ul class="toc"> |
|
|
163 |
<li> |
|
|
164 |
<a href="#start-contextually">Using CSS Fonts In Specific Contexts</a> |
|
|
165 |
</li> |
|
|
166 |
</ul> |
|
|
167 |
</li> |
|
|
168 |
</ul> |
|
|
169 |
</div> |
|
|
170 |
</div> |
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
<div class="sidebox"> |
|
|
175 |
<div class="hd"> |
|
|
176 |
<h2 class="no-toc">Examples</h2> |
|
|
177 |
</div> |
|
|
178 |
|
|
|
179 |
<div class="bd"> |
|
|
180 |
<ul class="examples"> |
|
|
181 |
|
|
|
182 |
|
|
|
183 |
<li data-description="When CSS Fonts is included in a page, it applies a baseline font treatment to all HTML elements. This baseline is Arial at the equivalent of 13px size and 16px line-height."> |
|
|
184 |
<a href="cssfonts-basic.html">Global (Page-Level) Example</a> |
|
|
185 |
</li> |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
<li data-description="Use the alternate contextual version of YUI Fonts to have precise control over which regions of the page are targeted."> |
|
|
190 |
<a href="cssfonts-context.html">Contextual Example</a> |
|
|
191 |
</li> |
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
<li data-description="Define all non-baseline sizes in percentages when using YUI Fonts."> |
|
|
196 |
<a href="cssfonts-size.html">Setting Font Size</a> |
|
|
197 |
</li> |
|
|
198 |
|
|
|
199 |
|
|
|
200 |
</ul> |
|
|
201 |
</div> |
|
|
202 |
</div> |
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
</div> |
|
|
207 |
</div> |
|
|
208 |
</div> |
|
|
209 |
</div> |
|
|
210 |
|
|
|
211 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
212 |
<script>prettyPrint();</script> |
|
|
213 |
|
|
|
214 |
<script> |
|
|
215 |
YUI.Env.Tests = { |
|
|
216 |
examples: [], |
|
|
217 |
project: '../assets', |
|
|
218 |
assets: '../assets/cssfonts', |
|
|
219 |
name: 'cssfonts', |
|
|
220 |
title: 'CSS Fonts', |
|
|
221 |
newWindow: '', |
|
|
222 |
auto: false |
|
|
223 |
}; |
|
|
224 |
YUI.Env.Tests.examples.push('cssfonts-basic'); |
|
|
225 |
YUI.Env.Tests.examples.push('cssfonts-context'); |
|
|
226 |
YUI.Env.Tests.examples.push('cssfonts-size'); |
|
|
227 |
|
|
|
228 |
</script> |
|
|
229 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
</body> |
|
|
234 |
</html> |