clip

CSS clip Property

The clip property allows a rectangle to clip a positioned element. The rectangle is specified as four coordinates: top, right, bottom, left. The values of top and bottom specify offsets from the inside top border edge of the box, while the values of right and left specify offsets from the inside left border edge of the box. All four sides may be either a length or auto. “Auto” is the default value.

The clip property does not work if the value of the overflow property is set to visible.

If possible the newer clip-path property can be used instead because the clip property is deprecated.

类目类目
Initial Valueauto
Applies to“Absolutely” positioned elements.
InheritedNo.
AnimatableYes. Background-color is animatable.
VersionCSS2
DOM Syntaxobject.style.clip = “rect(10px,40px,40px,10px)”;

Syntax

Syntax

clip: auto | shape | initial | inherit;

Example of the clip property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      img {
        position: absolute;
        clip: auto;
      }
    </style>
  </head>
  <body>
    <img src="/uploads/media/default/0001/01/003e5c463668d174ab70bea245c192d81901a4a6.png" alt="w3cdoc.com">
  </body>
</html>

Result

In the following example the rectangle clips the image according to the set values.

Example of the clip property with the “rect” value:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      img {
        position: absolute;
        clip: rect(0px, 70px, 200px, 0px);
      }
    </style>
  </head>
  <body>
    <img src="/uploads/media/default/0001/01/003e5c463668d174ab70bea245c192d81901a4a6.png" alt="w3cdoc.com logo">
  </body>
</html>

Values

Values

ValueDescriptionPlay it
autoDoes not clip an element. This is defautl value.Play it »
shapeClips an element. The only valid value is: rect (top, right, bottom, left).Play it »
initialIt makes the property use its default value.Play it »
inheritIt inherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部