⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syndata.html

📁 CSS lets learn this step by step...
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<P> Some properties allow negative length values, but this maycomplicate the formatting model and there may beimplementation-specific limits. If a negative length value cannot besupported, it should be converted to the nearest value that can besupported.<P><a name="absrel-units">There are two types of length units:relative and absolute.</a> <a name="x34"><span class="index-def" title="relativeunits"><em>Relative length</em></span></a> units specify a length relativeto another length property. Style sheets that use relative units willmore easily scale from one medium to another (e.g., from a computerdisplay to a laser printer).<P>Relative units are:<ul><li><strong>em</strong>: the <a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a> of the relevant font<li><strong>ex</strong>: the <span class="descinst">'x-height'</span> of the relevant font<li><strong>px</strong>: pixels, relative to the viewing device</ul><div class="example"><P style="display:none">Example(s):</P><P><PRE>H1 { margin: 0.5em }      /* em */H1 { margin: 1ex }        /* ex */P  { font-size: 12px }    /* px */</PRE></div><P>The <span class="index-def" title="em (unit)|quad width"><aname="em-width">'em'</a></span> unit is equal to the computed value ofthe <a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a> property ofthe element on which it is used. The exception is when 'em' occurs inthe value of the 'font-size' property itself, in which case it refersto the font size of the parent element. It may be used for vertical orhorizontal measurement. (This unit is also sometimes called thequad-width in typographic texts.)<p>The <span class="index-def" title="x-height|ex (unit)"><aname="ex">'ex'</a></span> unit is defined by the font's <a href="fonts.html#descdef-x-height" class="noxref"><spanclass="descinst-x-height">'x-height'</span></a>. The x-height is so calledbecause it is often equal to the height of the lowercase "x". However,an 'ex' is defined even for fonts that don't contain an "x".<div class="example"><P style="display:none">Example(s):</P><P>The rule:<PRE>H1 { line-height: 1.2em }</PRE><P>means that the line height of H1 elements will be 20% greaterthan the font size of the H1 elements. On the other hand:<PRE>H1 { font-size: 1.2em }</PRE><P>means that the font-size of H1 elements will be 20% greater thanthe font size inherited by H1 elements.</div><P>When specified for the root of the <a href="conform.html#doctree">document tree</a> (e.g., "HTML" in HTML), 'em' and 'ex' refer tothe property's <a href="cascade.html#initial-value">initial value</a>.<P><a name="pixel-units">Pixel units</a> are relative to theresolution of the viewing device, i.e., most often a computerdisplay. If the pixel density of the output device is very differentfrom that of a typical computer display, the user agent should rescalepixel values. It is recommended that the <a name="x39"><span class="index-def"title="reference pixel|pixel"><EM>reference pixel</EM></span></a> be thevisual angle of one pixel on a device with a pixel density of 90dpiand a distance from the reader of an arm's length. For a nominal arm'slength of 28 inches, the visual angle is therefore about 0.0227degrees.<p>For reading at arm's length, 1px thus corresponds to about 0.28&nbsp;mm(1/90&nbsp;inch). When printed on a laser printer, meant for reading at alittle less than arm's length (55&nbsp;cm, 21&nbsp;inches), 1px is about0.21&nbsp;mm. On a 300 dots-per-inch (dpi) printer, that may berounded up to 3 dots (0.25&nbsp;mm); on a 600&nbsp;dpi printer, it canbe rounded to 5 dots.<p>The two images below illustrate the effect of viewing distance onthe size of a pixel and the effect of a device's resolution. In thefirst image, a reading distance of 71&nbsp;cm (28&nbsp;inch) resultsin a px of 0.28&nbsp;mm, while a reading distance of 3.5&nbsp;m(12&nbsp;feet) requires a px of 1.4&nbsp;mm. </p><div class="figure"><p><img src="images/pixel1.gif" alt="Showing that pixels must becomelarger if the viewing distance increases"><SPAN class="dlink">&nbsp;&nbsp;&nbsp;<A name="img-pixel1" href="images/longdesc/pixel1-desc.html" title="Long description for the illustration of a pixel's definition">[D]</A></SPAN> </p></div><P>In the second image, anarea of 1px by 1px is covered by a single dot in a low-resolutiondevice (a computer screen), while the same area is covered by 16 dotsin a higher resolution device (such as a 400&nbsp;dpi laser printer).</p><div class="figure"><P><imgsrc="images/pixel2.gif" alt="Showing that more device pixels (dots)are needed to cover a 1px by 1px area on a high-resolution device thanon a low-res one"><SPAN class="dlink">&nbsp;&nbsp;&nbsp;<A name="img-pixel2" href="images/longdesc/pixel2-desc.html" title="Long description for the illustration of referencevs. device pixel">[D]</A></SPAN></p></div><P>Child elements do not inherit the relative values specified fortheir parent; they (generally) inherit the <ahref="cascade.html#computed-value">computed values</a>.</p><div class="example"><P style="display:none">Example(s):</P><P> In the following rules, the computed <a href="text.html#propdef-text-indent" class="noxref"><spanclass="propinst-text-indent">'text-indent'</span></a> value of H1 elementswill be 36pt, not 45pt, if H1 is a child of the BODY element.<PRE>BODY {  font-size: 12pt;  text-indent: 3em;  /* i.e., 36pt */}H1 { font-size: 15pt }</PRE></div><P><a name="x41"><span class="index-def" title="absolute length"><em> Absolutelength</em></span></a> units are only useful when the physical propertiesof the output medium are known. The absolute units are:<UL><LI><STRONG>in</STRONG>: inches -- 1 inch is equal to 2.54 centimeters.<LI><STRONG>cm</STRONG>: centimeters<LI><STRONG>mm</STRONG>: millimeters<LI><STRONG>pt</STRONG>: points -- the points used by CSS2 are equal to 1/72th of an inch. <LI><STRONG>pc</STRONG>: picas -- 1 pica is equal to 12 points.</UL><div class="example"><P style="display:none">Example(s):</P><P><PRE>H1 { margin: 0.5in }      /* inches  */H2 { line-height: 3cm }   /* centimeters */H3 { word-spacing: 4mm }  /* millimeters */H4 { font-size: 12pt }    /* points */H4 { font-size: 1pc }     /* picas */</PRE></div><P> In cases where the specified length cannot be supported, useragents must approximate it in the actual value.<H3>4.3.3  <A NAME="percentage-units">Percentages</A></H3><P> The format of a percentage value (denoted by <spanclass="index-def" title="&lt;percentage&gt;::definition of"><aname="value-def-percentage"class="value-def">&lt;percentage&gt;</a></span> in this specification)is an optional sign character ('+' or '-', with '+' being the default)immediately followed by a <span class="index-inst"title="&lt;number&gt;"><a name="x43" href="syndata.html#value-def-number" class="noxref"><spanclass="value-inst-number">&lt;number&gt;</span></a></span> immediatelyfollowed by '%'.<P> Percentage values are always relative to another value, forexample a length. Each property that allows percentages also definesthe value to which the percentage refers. The value may be that ofanother property for the same element, a property for an ancestorelement, or a value of the formatting context (e.g., the width of a <ahref="visuren.html#containing-block">containing block</a>). When apercentage value is set for a property of the <ahref="conform.html#root">root</a> element and the percentage isdefined as referring to the inherited value of some property, theresultant value is the percentage times the <ahref="cascade.html#initial-value">initial value</a> of that property.<div class="example"><P style="display:none">Example(s):</P><P> Since child elements (generally) inherit the <ahref="cascade.html#computed-value">computed values</a> of their parent, inthe following example, the children of the P element will inherit avalue of 12pt for <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a>, not the percentagevalue (120%):<PRE>P { font-size: 10pt }P { line-height: 120% }  /* 120% of 'font-size' */</PRE></div><H3>4.3.4 <A NAME="uri">URL + URN = URI</A></H3><P><a name="x44"><span class="index-def" title="Uniform Resource Locator (URL)|URL(Uniform Resource Locator)">URLs</span></a> (Uniform Resource Locators,see <a href="refs.html#ref-RFC1738" rel="biblioentry" class="noxref"><span class="normref">[RFC1738]</span></a> and <a href="refs.html#ref-RFC1808" rel="biblioentry" class="noxref"><span class="normref">[RFC1808]</span></a>) provide the address of a resource onthe Web. An expected new way of identifying resources is called <a name="x46"><spanclass="index-def" title="URN (Uniform Resource Name)|Uniform ResourceName (URN)">URN</span></a> (Uniform Resource Name). Together they arecalled <a name="x48"><span class="index-def" title="Resource Identifier (URI)|URI(Uniform Resource Identifier)">URIs</span></a> (Uniform ResourceIdentifiers, see <a href="refs.html#ref-URI" rel="biblioentry" class="noxref"><span class="normref">[URI]</span></a>). This specification uses the term URI.<P>URI values in this specification are denoted by <spanclass="index-def" title="&lt;uri&gt;::definition of"><aname="value-def-uri" class="value-def">&lt;uri&gt;</a></span>.  Thefunctional notation used to designate URIs in property values is"url()", as in:<div class="example"><P style="display:none">Example(s):</P><P><PRE>BODY { background: url("http://www.bg.com/pinkish.gif") }</PRE></div><P> The format of a URI value is 'url(' followed by optional <ahref="#whitespace">whitespace</a> followed by an optional single quote(') or double quote (") character followed by the URIitself, followed by an optional single quote (') or double quote (")character followed by optional whitespace followed by')'. The two quote characters must be the same.<div class="example"><P style="display:none">Example(s):</P><P>An example without quotes:<PRE>LI { list-style: url(http://www.redballs.com/redball.png) disc }</PRE></div><P> Parentheses, commas, whitespace characters, single quotes (') anddouble quotes (") appearing in a URI must be escaped with abackslash: '\(', '\)', '\,'.<P>Depending on the type of URI, it might also be possible to writethe above characters as URI-escapes (where "(" = %28, ")" = %29, etc.)as described in <a href="refs.html#ref-URI" rel="biblioentry" class="noxref"><span class="normref">[URI]</span></a>.<P> In order to create modular style sheets that are not dependent onthe absolute location of a resource, authors may use relative URIs.Relative URIs (as defined in <a href="refs.html#ref-RFC1808" rel="biblioentry" class="noxref"><span class="normref">[RFC1808]</span></a>) are resolved to full URIsusing a base URI. RFC&nbsp;1808, section&nbsp;3, defines the normativealgorithm for this process. For CSS style sheets, the base URI is thatof the style sheet, not that of the source document.<div class="example"><P style="display:none">Example(s):</P><P>For example, suppose the following rule:</p><PRE>BODY { background: url("yellow") }</PRE><P>is located in a style sheet designated by the URI:</p><PRE>http://www.myorg.org/style/basic.css</PRE><P>The background of the source document's BODY will be tiled withwhatever image is described by the resource designatedby the URI<PRE>http://www.myorg.org/style/yellow</PRE></div><P>User agents may vary in how they handle URIs that designateunavailable or inapplicable resources.<H3>4.3.5 <a name="counter">Counters</a></h3><p><span class="index-def" title="&lt;counter&gt;, definition of"><aname="value-def-counter">Counters</a></span> are denoted byidentifiers (see the <a href="generate.html#propdef-counter-increment" class="noxref"><spanclass="propinst-counter-increment">'counter-increment'</span></a> and<a href="generate.html#propdef-counter-reset" class="noxref"><span class="propinst-counter-reset">'counter-reset'</span></a>properties). To refer to the value of a counter, the notation<a name="x52"><span class="index-def" title="counter()">'counter(&lt;identifier&gt;)'</span></a> or 'counter(&lt;identifier&gt;,&lt;list-style-type&gt;)' is used.  The default style is 'decimal'.<p>To refer to a sequence of nested counters of the same name, thenotation is 'counters(&lt;identifier&gt;, &lt;string&gt;)' or'counters(&lt;identifier&gt;, &lt;string&gt;,&lt;list-style-type&gt;)'. See <a href="generate.html#scope">"Nestedcounters and scope"</a> in the chapter on <ahref="generate.html">generated content</a>.<p>In CSS2, the values of counters canonly be referred to from the <a href="generate.html#propdef-content" class="noxref"><spanclass="propinst-content">'content'</span></a> property. Note that 'none'is a possible &lt;list-style-type&gt;: 'counter(x,none)' yields an empty string.<div class="example"><P style="display:none">Example(s):</P><p>Here is a style sheet that numbers paragraphs (P) for each chapter(H1). The paragraphs are numbered with roman numerals, followed by aperiod and a space:<pre>P {counter-increment: par-num}H1 {counter-reset: par-num}P:before {content: counter(par-num, upper-roman) ". "}</pre></div><p>Counters that are not in the <ahref="generate.html#scope">scope</a> of any 'counter-reset', areassumed to have been reset to 0 by a 'counter-reset' on the rootelement.<H3>4.3.6 <a name="color-units">Colors</a></H3>A <span class="index-def" title="&lt;color&gt;::definition of"><aname="value-def-color" class="value-def">&lt;color&gt;</a></span>is either a keyword or a numerical RGB specification.<P> The list of keyword color names is: aqua, black, blue, fuchsia,gray, green, lime, maroon, navy, olive, purple, red, silver, teal,white, and yellow. These 16 colors are defined in HTML 4.0(<a href="refs.html#ref-HTML40" rel="biblioentry" class="noxref"><span class="informref">[HTML40]</span></a>). In addition to these color keywords, users may specifykeywords that correspond to the colors used by certain objects in theuser's environment. Please consult the section on <ahref="./ui.html#system-colors">system colors</a> for more information.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -