1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Visual effects</title>
<link rel="stylesheet" href="style/default.css" type="text/css">
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-CR.css" type="text/css">
<link rel="prev" href="visudet.html">
<link rel="next" href="generate.html">
<link rel="contents" href="cover.html#minitoc">
<link rel="CSS-properties" href="propidx.html" title="properties">
<link rel="index" href="indexlist.html" title="index">
<link rel="first" href="cover.html">
<meta name="editor" lang="tr" content="Tantek Çelik">
<style type="text/css">
.current,.proposed,span.delcurrent { background:#feb }
ins.proposed,span.insproposed { background:#bfb }
del.proposed,span.delproposed { background:#fbb }
span.insproposed { text-decoration:underline }
span.delproposed,span.delcurrent { text-decoration:line-through }
body>del,body>ins {display:block}
</style>
</head>
<body>
<div class="navbar">
<p><a href="visudet.html">previous</a>
<a href="generate.html">next</a>
<a href="cover.html#minitoc">contents</a>
<a href="propidx.html">properties</a>
<a href="indexlist.html">index</a>
</div>
<hr class="navbar">
<h1><a name="q0">11 Visual effects</a></h1>
<div class="subtoc">
<p><strong>Contents</strong>
<ul class="toc">
<li class="tocline2"><a href="visufx.html#overflow-clipping" class="tocxref">11.1 Overflow and clipping</a>
<ul class="toc">
<li class="tocline3"><a href="visufx.html#overflow" class="tocxref">11.1.1 Overflow: the <span class="propinst-overflow">'overflow'</span> property</a>
<li class="tocline3"><a href="visufx.html#clipping" class="tocxref">11.1.2 Clipping: the <span class="propinst-clip">'clip'</span> property</a>
</ul>
<li class="tocline2"><a href="visufx.html#visibility" class="tocxref">11.2 Visibility: the <span class="propinst-visibility">'visibility'</span> property</a>
</ul>
</div>
<h2>11.1 <a name="overflow-clipping">Overflow and clipping</a></h2>
<p>Generally, the content of a block box is confined to the
content edges of the box. In certain cases, a box may <a name="x0"><span
class="index-def"
title="overflow|box::overflow"><dfn>overflow</dfn></span></a>, meaning its
content lies partly or entirely outside of the box, e.g.:</p>
<ul>
<li>A line cannot be broken, causing the line box to be wider than the
block box.
</li>
<li>A block-level box is too wide for the containing block. This may
happen when an
element's <a href="visudet.html#propdef-width" class="noxref"><span class="propinst-width">'width'</span></a> property has a
value that causes the generated block box to spill over
sides of the containing block.
</li>
<li>An element's height exceeds an explicit height assigned to the containing
block (i.e., the containing block's height is determined by the <a href="visudet.html#propdef-height" class="noxref"><span
class="propinst-height">'height'</span></a> property, not by content
height).
</li>
<li>A descendent box is <a href="visuren.html#absolute-positioning">positioned
absolutely</a>, partly outside the box. Such boxes are not always clipped by the overflow property on their ancestors.
</li>
<li>A descendent box has <a href="box.html#margin-properties">negative margins</a>, causing it
to be positioned partly outside the box.
</li>
<li>The 'text-indent' property causes an inline box to hang off either the left or right edge of the block box.
</li>
</ul>
<p>Whenever overflow occurs, the <a href="visufx.html#propdef-overflow" class="noxref"><span
class="propinst-overflow">'overflow'</span></a> property specifies
whether a box is clipped to its padding edge, and if so, whether
a scrolling mechanism is provided to access any clipped out content.
</p>
<h3>11.1.1 <a name="overflow">Overflow</a>: the <a href="visufx.html#propdef-overflow" class="noxref"><span
class="propinst-overflow">'overflow'</span></a> property</h3>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'overflow'"><a name="propdef-overflow" class="propdef-title"><strong>'overflow'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>visible | hidden | scroll | auto | <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>visible
<tr valign=baseline><td><em>Applies to:</em> <td>non-replaced block-level elements, table cells, and inline-block 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>
<tr valign=baseline><td><em>Computed value:</em> <td>as specified
</table>
</dl>
</div>
<p>
This property specifies whether content of a block-level element is
clipped when it overflows the element's box. It affects the clipping
of all of the element's content except any descendant elements (and
their respective content and descendants) whose containing block is the viewport or an ancestor of the element. Values have the following meanings:
</p>
<dl>
<dt><strong>visible</strong></dt>
<dd>This value indicates that content is not clipped, i.e., it
may be rendered outside the block box.
</dd>
<dt><strong>hidden</strong></dt>
<dd>This value indicates that the content is clipped and that no
scrolling user interface should be provided to view the content outside the
clipping region.
</dd>
<dt><strong>scroll</strong></dt>
<dd>This value indicates that the content is clipped and that if the
user agent uses a scrolling mechanism that is visible on the screen
(such as a scroll bar or a panner), that mechanism should be displayed
for a box whether or not any of its content is clipped. This avoids
any problem with scrollbars appearing and disappearing in a dynamic
environment.
When this value is specified and the target medium is
'print', overflowing content may be printed.
</dd>
<dt><strong>auto</strong></dt>
<dd>The behavior of the 'auto' value is user agent-dependent, but
should cause a scrolling mechanism to be provided for overflowing boxes.
</dd>
</dl>
<p> Even if <a href="visufx.html#propdef-overflow" class="noxref"><span class="propinst-overflow">'overflow'</span></a> is set
to 'visible', content may be clipped to a UA's document window by the
native operating environment.
</p>
<p>
UAs must apply the 'overflow' property set on the root element to
the viewport.
When the root element is an HTML "HTML" element or an XHTML "html"
element, and that element has an HTML "BODY" element or an XHTML
"body" element as a child, user agents must instead apply the
'overflow' property from the first such child element to the
viewport, if the value on the root element is 'visible'.
The 'visible' value when used for the viewport
must be interpreted as 'auto'. The element from which the value is
propagated must have a used value for 'overflow' of 'visible'.
</p>
<p>
In the case of a scrollbar being placed on an edge of the element's
box, it should be inserted between the inner border edge and the outer
padding edge. Any space taken up by the scrollbars should be taken out
of (subtracted from the dimensions of) the containing block formed by
the element with the scrollbars.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
Consider the following example of a block quotation
(<code><blockquote></code>) that is too big
for its containing block (established by a <code><div></code>). Here is
the source:</p>
<pre class="html-example"><code class="html">
<div>
<blockquote>
<p>I didn't like the play, but then I saw
it under adverse conditions - the curtain was up.</p>
<cite>- Groucho Marx</cite>
</blockquote>
</div>
</code></pre>
<p>Here is the style sheet controlling the sizes and style of the
generated boxes:
</p>
<pre><code class="css">
div { width : 100px; height: 100px;
border: thin solid red;
}
blockquote { width : 125px; height : 100px;
margin-top: 50px; margin-left: 50px;
border: thin dashed black
}
cite { display: block;
text-align : right;
border: none
}
</code></pre>
<p>The initial value of <a href="visufx.html#propdef-overflow" class="noxref"><span
class="propinst-overflow">'overflow'</span></a> is 'visible', so
the <code><blockquote></code> would be formatted without clipping, something like this:</p>
<div class="figure">
<p><img src="images/overflow1.png" alt="Rendered overflow"><SPAN class="dlink"> <A name="img-overflow1" href="images/longdesc/overflow1-desc.html" title="Long description for example with unclipped overflow">[D]</A></SPAN></p>
</div>
<p>Setting <a href="visufx.html#propdef-overflow" class="noxref"><span class="propinst-overflow">'overflow'</span></a> to
'hidden' for the <code><div></code>, on the other hand, causes the
<code><blockquote></code> to be clipped by the containing block:
</p>
<div class="figure">
<p><img src="images/overflow2.png" alt="Clipped overflow"><SPAN class="dlink"> <A name="img-overflow2" href="images/longdesc/overflow2-desc.html" title="Long description for example with clipped overflow">[D]</A></SPAN></p>
</div>
<p>A value of 'scroll' would tell UAs that support
a visible scrolling mechanism to display one so that users
could access the clipped content.
</p>
</div>
<div>
<p>
Finally, consider this case where an absolutely positioned element
is mixed with an overflow parent.
</p>
<p>
Style sheet:
</p>
<pre><code class="html">
container { position: relative; border: solid; }
scroller { overflow: scroll; height: 5em; margin: 5em; }
satellite { position: absolute; top: 0; }
body { height: 10em; }
</code></pre>
<p>
Document fragment:
</p>
<pre><code class="xml">
<container>
<scroller>
<satellite/>
<body/>
</scroller>
</container>
</code></pre>
<p>
In this example, the "scroller" element will not scroll the
"satellite" element, because the latter's containing block is outside
the element whose overflow is being clipped and scrolled.
</p>
</div>
<h3>11.1.2 <a name="clipping">Clipping</a>: the <a href="visufx.html#propdef-clip" class="noxref"><span
class="propinst-clip">'clip'</span></a> property</h3>
<p>A <a name="x3"><span class="index-def" title="clipping region"><dfn>clipping
region</dfn></span></a> defines what portion of an element's
border box
is visible. By default, the element is not clipped. However, the clipping region may be explicitly set with the <a href="visufx.html#propdef-clip" class="noxref"><span class="propinst-clip">'clip'</span></a> property.
</p>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'clip'"><a name="propdef-clip" class="propdef-title"><strong>'clip'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td><a href="visufx.html#value-def-shape" class="noxref"><span class="value-inst-shape"><shape></span></a> | auto | <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>auto
<tr valign=baseline><td><em>Applies to:</em> <td>absolutely positioned 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>
<tr valign=baseline><td><em>Computed value:</em> <td>For rectangle values, a rectangle consisting of four computed
lengths; otherwise, as specified
</table>
</dl>
</div>
<p>The 'clip' property applies only to absolutely positioned elements.
Values have the following meanings:</p>
<dl>
<dt><strong>auto</strong></dt>
<dd>The element does not clip.</dd>
<dt><span class="index-def" title="<shape>::definition of"><a
name="value-def-shape"
class="value-def"><strong><shape></strong></a></span></dt>
<dd>In CSS 2.1, the only valid <shape> value is:
rect(<a href="visufx.html#value-def-top" class="noxref"><span
class="value-inst-top"><top></span></a>, <a href="visufx.html#value-def-right" class="noxref"><span
class="value-inst-right"><right></span></a>, <a href="visufx.html#value-def-bottom" class="noxref"><span
class="value-inst-bottom"><bottom></span></a>, <a href="visufx.html#value-def-left" class="noxref"><span
class="value-inst-left"><left></span></a>)
where <a href="visufx.html#value-def-top" class="noxref"><span class="value-inst-top"><top></span></a> and <a href="visufx.html#value-def-bottom" class="noxref"><span
class="value-inst-bottom"><bottom></span></a> specify offsets from
the top border edge of the box, and <a href="visufx.html#value-def-right" class="noxref"><span
class="value-inst-right"><right></span></a>, and <a href="visufx.html#value-def-left" class="noxref"><span
class="value-inst-left"><left></span></a> specify offsets from the
left border edge of the box in left-to-right text and from the right
border edge of the box in right-to-left text. Authors should separate
offset values with commas. User agents must support separation with
commas, but may also support separation without commas (but not a
combination), because a
previous revision of this specification was ambiguous in this respect.
<p><span class="index-def" title="<top>::definition of"><a
name="value-def-top" class="value-def"><top></a></span>, <span
class="index-def" title="<right>::definition of"><a
name="value-def-right" class="value-def"><right></a></span>,
<span class="index-def" title="<bottom>::definition of"><a
name="value-def-bottom" class="value-def"><bottom></a></span>,
and <span class="index-def" title="<left>::definition of"><a
name="value-def-left" class="value-def"><left></a></span> may
either have a <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a>
value or 'auto'. Negative lengths are permitted. The value 'auto'
means that a given edge of the clipping region will be the same as the
edge of the element's generated border box (i.e., 'auto' means the same as '0' for <a href="visufx.html#value-def-top" class="noxref"><span class="value-inst-top"><top></span></a> and <a href="visufx.html#value-def-left" class="noxref"><span
class="value-inst-left"><left></span></a> (in left-to-right text,
<a href="visufx.html#value-def-right" class="noxref"><span class="value-inst-right"><right></span></a> in right-to-left
text), the same as the computed value of the height plus the sum of
vertical padding and border widths for <a href="visufx.html#value-def-right" class="noxref"><span
class="value-inst-right"><bottom></span></a>, and the same as the
computed value of the width plus the sum of the horizontal padding and
border widths for <a href="visufx.html#value-def-right" class="noxref"><span class="value-inst-right"><right></span></a>
(in left-to-right text, <a href="visufx.html#value-def-right" class="noxref"><span
class="value-inst-right"><left></span></a> in right-to-left text),
such that four 'auto' values result in the clipping region being
the same as the element's border box).
</p>
<p>When coordinates are rounded to pixel coordinates, care should be
taken that no pixels remain visible when <left> and
<right> have the same value (or <top> and <bottom>
have the same value), and conversely that no pixels within the
element's border box remain hidden when these values are 'auto'.
</p>
</dd>
</dl>
<p>An element's clipping region clips out any aspect of the element (e.g. content, children, background, borders, text decoration, outline and visible scrolling mechanism — if any) that is outside the clipping region.
Content that has been clipped does not cause overflow.
</p>
<p>The element's ancestors may also clip portions of their content (e.g. via their own <a href="visufx.html#propdef-clip" class="noxref"><span class="propinst-clip">'clip'</span></a> property and/or if
their <a href="visufx.html#propdef-overflow" class="noxref"><span class="propinst-overflow">'overflow'</span></a> property is
not 'visible'); what is rendered is the cumulative intersection.
</p>
<p>If the clipping region exceeds the bounds of the UA's
document window, content may be clipped to that window by the
native operating environment.
</p>
<div class="example"><P style="display:none">Example(s):</P><p>
The following two rules:</p>
<pre><code class="css">
p { clip: rect(5px, 40px, 45px, 5px); }
p { clip: rect(5px, 55px, 45px, 5px); }
</code></pre>
<p>will create the rectangular clipping regions delimited
by the dashed lines in the following illustrations:</p>
<div class="figure">
<p><img src="images/clip.png" alt="Two clipping regions"><SPAN class="dlink"> <A name="img-clip" href="images/longdesc/clip-desc.html" title="Long description for example of clipping region">[D]</A></SPAN></p>
</div>
</div>
<div class="note"><p> <em><strong>Note.</strong> In CSS 2.1, all clipping
regions are rectangular. We anticipate future extensions to permit
non-rectangular clipping. Future updates may also reintroduce a
syntax for offsetting shapes from each edge instead of offsetting from
a point.</em></p></div>
<h2>11.2 <a name="visibility">Visibility</a>: the <a href="visufx.html#propdef-visibility" class="noxref"><span
class="propinst-visibility">'visibility'</span></a> property</h2>
<div class="propdef">
<dl><dt>
<span class="index-def" title="'visibility'"><a name="propdef-visibility" class="propdef-title"><strong>'visibility'</strong></a></span>
<dd>
<table class="propinfo" cellspacing=0 cellpadding=0>
<tr valign=baseline><td><em>Value:</em> <td>visible | hidden | collapse | <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>visible
<tr valign=baseline><td><em>Applies to:</em> <td>all elements
<tr valign=baseline><td><em>Inherited:</em> <td>yes
<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>
<tr valign=baseline><td><em>Computed value:</em> <td>as specified
</table>
</dl>
</div>
<p>The <a href="visufx.html#propdef-visibility" class="noxref"><span class="propinst-visibility">'visibility'</span></a> property
specifies whether the boxes generated by an element are
rendered. Invisible boxes still affect layout (set the <a href="visuren.html#propdef-display" class="noxref"><span
class="propinst-display">'display'</span></a> property to 'none' to
suppress box generation altogether). Values have the following
meanings:</p>
<dl>
<dt><strong>visible</strong></dt>
<dd>The generated box is visible.</dd>
<dt><strong>hidden</strong></dt>
<dd>The generated box is invisible (fully transparent, nothing is drawn), but still
affects layout. Furthermore, descendents of the element will
be visible if they have 'visibility: visible'.</dd>
<dt><strong>collapse</strong></dt>
<dd>Please consult the section on
<a href="tables.html#dynamic-effects">dynamic row and column
effects</a> in tables. If used on elements other than rows, row groups, columns, or column groups,
'collapse' has the same meaning as 'hidden'.
</dd>
</dl>
<p>This property may be used in conjunction with scripts to create
dynamic effects.
</p>
<div class="html-example"><p> In the following example, pressing
either form button invokes an author-defined script function that causes
the corresponding box to become visible and the other to be
hidden. Since these boxes have the same size and position, the effect
is that one replaces the other. (The script code is in a hypothetical
script language. It may or may not have any effect in a CSS-capable
UA.)
</p>
<pre><code class="html">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD><TITLE>Dynamic visibility example</TITLE>
<META
http-equiv="Content-Script-Type"
content="application/x-hypothetical-scripting-language">
<STYLE type="text/css">
<!--
#container1 { position: absolute;
top: 2in; left: 2in; width: 2in }
#container2 { position: absolute;
top: 2in; left: 2in; width: 2in;
visibility: hidden; }
-->
</STYLE>
</HEAD>
<BODY>
<P>Choose a suspect:</P>
<DIV id="container1">
<IMG alt="Al Capone"
width="100" height="100"
src="suspect1.png">
<P>Name: Al Capone</P>
<P>Residence: Chicago</P>
</DIV>
<DIV id="container2">
<IMG alt="Lucky Luciano"
width="100" height="100"
src="suspect2.png">
<P>Name: Lucky Luciano</P>
<P>Residence: New York</P>
</DIV>
<FORM method="post"
action="http://www.suspect.org/process-bums">
<P>
<INPUT name="Capone" type="button"
value="Capone"
onclick='show("container1");hide("container2")'>
<INPUT name="Luciano" type="button"
value="Luciano"
onclick='show("container2");hide("container1")'>
</FORM>
</BODY>
</HTML>
</code></pre>
</div>
<hr class="navbar">
<div class="navbar">
<p><a href="visudet.html">previous</a>
<a href="generate.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>
|