📄 colors.html
字号:
<div class="propdef"><dl><dt><span class="index-def" title="'background-attachment'"><a name="propdef-background-attachment" class="propdef-title"><strong>'background-attachment'</strong></a></span><dd><table class="propinfo" cellspacing=0 cellpadding=0><tr valign=baseline><td><em>Value:</em> <td>scroll | fixed | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a><tr valign=baseline><td><em>Initial:</em> <td>scroll<tr valign=baseline><td><em>Applies to:</em> <td>all elements<tr valign=baseline><td><em>Inherited:</em> <td>no<tr valign=baseline><td><em>Percentages:</em> <td>N/A<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a></table></dl></div><P>If a background image is specified, this property specifieswhether it is fixed with regard to the <ahref="visuren.html#viewport">viewport</a> ('fixed') or scrolls along with thedocument ('scroll').<p>Even if the image is fixed, it is still only visible when it is inthe background or padding area of the element. Thus, unless the imageis tiled ('background-repeat: repeat'), it may be invisible.<div class="example"><P style="display:none">Example(s):</P><P>This example creates an infinite vertical bandthat remains "glued" to the viewport when the element is scrolled.<PRE>BODY { background: red url("pendant.gif"); background-repeat: repeat-y; background-attachment: fixed;}</PRE></div><P>User agents may treat 'fixed' as 'scroll'. However, it isrecommended they interpret 'fixed' correctly, at least for the HTML andBODY elements, since there is no way for an author to provide an imageonly for those browsers that support 'fixed'. See the section on <ahref="conform.html#conformance">conformance</a> for details.<div class="propdef"><dl><dt><span class="index-def" title="'background-position'"><a name="propdef-background-position" class="propdef-title"><strong>'background-position'</strong></a></span><dd><table class="propinfo" cellspacing=0 cellpadding=0><tr valign=baseline><td><em>Value:</em> <td>[ [<a href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage"><percentage></span></a> | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> ]{1,2} | [ [top | center | bottom] || [left | center | right] ] ] | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a><tr valign=baseline><td><em>Initial:</em> <td>0% 0%<tr valign=baseline><td><em>Applies to:</em> <td>block-level and replaced elements<tr valign=baseline><td><em>Inherited:</em> <td>no<tr valign=baseline><td><em>Percentages:</em> <td>refer to the size of the box itself<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a></table></dl></div><P> If a background image has been specified, this property specifiesits initial position. Values have the following meanings:</p><dl><dt><span class="index-inst" title="<percentage>"><a name="x8" href="syndata.html#value-def-percentage" class="noxref"><spanclass="value-inst-percentage"><strong><percentage></strong></span></a></span> <span class="index-inst" title="<percentage>"><a name="x9" href="syndata.html#value-def-percentage" class="noxref"><spanclass="value-inst-percentage"><strong><percentage></strong></span></a></span><dd> With a value pair of '0% 0%', the upper left corner of the imageis aligned with the upper left corner of the box's <ahref="box.html#padding-edge">padding edge</a>. A value pair of'100% 100%' places the lower right corner of the image in the lowerright corner of padding area. With a value pair of '14% 84%', the point14% across and 84% down the image is to be placed at the point 14%across and 84% down the padding area.<dt><span class="index-inst" title="<length>"><a name="x10" href="syndata.html#value-def-length" class="noxref"><spanclass="value-inst-length"><strong><length></strong></span></a></span> <span class="index-inst" title="<length>"><a name="x11" href="syndata.html#value-def-length" class="noxref"><spanclass="value-inst-length"><strong><length></strong></span></a></span><dd> With a value pair of '2cm 2cm', the upper left corner of the imageis placed 2cm to the right and 2cm below the upper left corner of thepadding area.<dt><dt><strong>top left</strong> and <strong>left top</strong><dd>Same as '0% 0%'.<dt><strong>top</strong>, <strong>top center</strong>, and <strong>center top</strong><dd>Same as '50% 0%'.<dt><strong>right top</strong> and <strong>top right</strong><dd>Same as '100% 0%'.<dt><strong>left</strong>, <strong>left center</strong>, and <strong>center left</strong><dd>Same as '0% 50%'.<dt><strong>center</strong> and <strong>center center</strong><dd>Same as '50% 50%'.<dt><strong>right</strong>, <strong>right center</strong>, and <strong>center right</strong><dd>Same as '100% 50%'.<dt><strong>bottom left</strong> and <strong>left bottom</strong><dd>Same as '0% 100%'.<dt><strong>bottom</strong>, <strong>bottom center</strong>, and <strong>center bottom</strong><dd>Same as '50% 100%'.<dt><strong>bottom right</strong> and <strong>right bottom</strong><dd>Same as '100% 100%'.</dl><P> If only one percentage or length value is given, it sets thehorizontal position only, the vertical position will be 50%. If twovalues are given, the horizontal position comes first. Combinations oflength and percentage values are allowed, (e.g., '50% 2cm'). Negativepositions are allowed. Keywords cannot be combined with percentagevalues or length values (all possible combinations are given above).<div class="example"><P style="display:none">Example(s):</P><P><PRE>BODY { background: url("banner.jpeg") right top } /* 100% 0% */BODY { background: url("banner.jpeg") top center } /* 50% 0% */BODY { background: url("banner.jpeg") center } /* 50% 50% */BODY { background: url("banner.jpeg") bottom } /* 50% 100% */</PRE></div><P> If the background image is fixed within the viewport (see the<a href="colors.html#propdef-background-attachment" class="noxref"><spanclass="propinst-background-attachment">'background-attachment'</span></a>property), the image is placed relative to the viewport instead of theelement's padding area. For example,<div class="example"><P style="display:none">Example(s):</P><P><PRE>BODY { background-image: url("logo.png"); background-attachment: fixed; background-position: 100% 100%; background-repeat: no-repeat;} </PRE><P> In the example above, the (single) image is placed in the lower-rightcorner of the viewport.</div><div class="propdef"><dl><dt><span class="index-def" title="'background'"><a name="propdef-background" class="propdef-title"><strong>'background'</strong></a></span><dd><table class="propinfo" cellspacing=0 cellpadding=0><tr valign=baseline><td><em>Value:</em> <td>[<a href="colors.html#propdef-background-color" class="noxref"><span class="propinst-background-color"><'background-color'></span></a> || <a href="colors.html#propdef-background-image" class="noxref"><span class="propinst-background-image"><'background-image'></span></a> || <a href="colors.html#propdef-background-repeat" class="noxref"><span class="propinst-background-repeat"><'background-repeat'></span></a>|| <a href="colors.html#propdef-background-attachment" class="noxref"><span class="propinst-background-attachment"><'background-attachment'></span></a> || <a href="colors.html#propdef-background-position" class="noxref"><span class="propinst-background-position"><'background-position'></span></a>] | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a><tr valign=baseline><td><em>Initial:</em> <td>not defined for shorthand properties<tr valign=baseline><td><em>Applies to:</em> <td>all elements<tr valign=baseline><td><em>Inherited:</em> <td>no<tr valign=baseline><td><em>Percentages:</em> <td>allowed on 'background-position'<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a></table></dl></div><P> The <a href="colors.html#propdef-background" class="noxref"><span class="propinst-background">'background'</span></a> propertyis a shorthand property for setting the individual backgroundproperties (i.e., <a href="colors.html#propdef-background-color" class="noxref"><spanclass="propinst-background-color">'background-color'</span></a>, <a href="colors.html#propdef-background-image" class="noxref"><spanclass="propinst-background-image">'background-image'</span></a>, <a href="colors.html#propdef-background-repeat" class="noxref"><spanclass="propinst-background-repeat">'background-repeat'</span></a>, <a href="colors.html#propdef-background-attachment" class="noxref"><spanclass="propinst-background-attachment">'background-attachment'</span></a>and <a href="colors.html#propdef-background-position" class="noxref"><spanclass="propinst-background-position">'background-position'</span></a>) atthe same place in the style sheet.<P> The <a href="colors.html#propdef-background" class="noxref"><span class="propinst-background">'background'</span></a> propertyfirst sets all the individual background properties to their initialvalues, then assigns explicit values given in the declaration.<div class="example"><P style="display:none">Example(s):</P><P> In the first rule of the following example, only a value for <a href="colors.html#propdef-background-color" class="noxref"><spanclass="propinst-background-color">'background-color'</span></a> has beengiven and the other individual properties are set to their initialvalue. In the second rule, all individual properties have beenspecified.<PRE>BODY { background: red }P { background: url("chess.png") gray 50% repeat fixed }</PRE></div><H2>14.3 <a name="gamma-correction">Gamma correction</a></H2><P><em>For information about gamma issues, please consult the theGamma Tutorial in the PNG specification (<a href="refs.html#ref-PNG10" rel="biblioentry" class="noxref"><span class="normref">[PNG10]</span></a>).</em></P><P> In the computation of gamma correction, UAs displaying on a CRTmay assume an ideal CRT and ignore any effects on apparent gammacaused by dithering. That means the minimal handling they need to doon current platforms is: <DL> <DT> PC using MS-Windows <DD> none <DT> Unix using X11 <DD> none <DT> Mac using QuickDraw <DD> apply gamma 1.45 <a href="refs.html#ref-ICC32" rel="biblioentry" class="noxref"><span class="normref">[ICC32]</span></a> (ColorSync-savvy applications may simply pass the sRGB ICC profile to ColorSync to perform correct color correction) <DT> SGI using X <DD> apply the gamma value from <TT>/etc/config/system.glGammaVal</TT> (the default value being 1.70; applications running on Irix 6.2 or above may simply pass the sRGB ICC profile to the color management system) <DT> NeXT using NeXTStep <DD> apply gamma 2.22 </DL><P>"Applying gamma" means that each of the three R, G and B must beconverted to R'=R<SUP>gamma</SUP>, G'=G<SUP>gamma</SUP>,B'=B<SUP>gamma</SUP>, before being handed to the OS.<P>This may rapidly be done by building a 256-element lookup tableonce per browser invocation thus:<PRE>for i := 0 to 255 do raw := i / 255.0; corr := pow (raw, gamma); table[i] := trunc (0.5 + corr * 255.0)end</PRE><P>which then avoids any need to do transcendental math per colorattribute, far less per pixel.<hr class="navbar"><div class="navbar" align="center"><p><a href="page.html">previous</a> <a href="fonts.html">next</a> <a href="cover.html#minitoc">contents</a> <a href="propidx.html">properties</a> <a href="indexlist.html">index</a> </div></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -