XML technologies / CSS / Advanced websites with CSS / CSS property reference / clip
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The property clip reduces the visible area of an HTML element positioned with absolute or fixed. The element retains its position on the page but is visible only within the specified area.
Unlike the CSS property overflow, only the visible area (including all box elements) is described. The element’s dimensions and position in the page structure are unchanged.
Inherited: no
See also: overflow
Values
CSS2 allows clip to define only rectangular areas. An area is defined with a command rect() including the coordinates of all four sides:
clip: rect (top right bottom left);
For an element x pixels wide and y pixels high, without a border or padding, the default clipping region is rect(0px xpx ypx 0). To trim ten pixels from each side of the image, use a value following the formula rect(10px x-10px y-10px 10px).
The default value auto lets the browser determine the element’s display area automatically.
Default value: auto
Compatibility
CSS version: 2
Works in all CSS-capable browsers, including Internet Explorer 4 and later, Netscape 4 and later, and Mozilla. Internet Explorer 4 for Macintosh renders incorrectly. Netscape 4 calculates the scrollbar size incorrectly.
Example
The following style rule reduces the visible area by ten pixels on both the right and left sides of the element with ID logo:
#logo {
position: absolute;
clip: rect(0px 90px 100px 10px);
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg