在线文档教程
CSS

剪辑 | clip

clip

已弃用

此功能已从Web标准中删除。虽然有些浏览器可能仍然支持它,但它正在被删除的过程中。如果可能,请避免使用它并更新现有代码;请参见兼容性表在这页的底部指导你的决定。请注意,此功能可能在任何时候停止工作。

clip属性定义了元素的哪一部分是可见的。clip属性只适用于position:absolute的元素,即position:absoluteposition:fixed...

/* Keyword value */ clip: auto; /* <shape> values */ clip: rect(1px 10em 3rem 2ch clip: rect(1px, 10em, 3rem, 2ch /* Global values */ clip: inherit; clip: initial; clip: unset;

语法

警告:此属性不受欢迎。使用clip-path相反。

Initial valueauto
Applies toabsolutely positioned elements
Inheritedno
Mediavisual
Computed valueauto if specified as auto, otherwise a rectangle with four values, each of which is auto if specified as auto or the computed length otherwise
Animation typea rectangle
Canonical orderthe unique non-ambiguous order defined by the formal grammar

<shape>一个矩形<shape>

形式语法

<shape> | autowhere <shape> = rect(<top>, <right>, <bottom>, <left>)

实例

.dotted-border { border: dotted; position: relative; width: 536px; height: 350px; } #top-left, #middle, #bottom-right { position: absolute; top: 0px; } #top-left { left: 360px; clip: rect(0px, 175px, 113px, 0px } #middle { left: 280px; clip: rect(119px, 255px, 229px, 80px /* standard syntax, unsupported by Internet Explorer 4-7 */ } #bottom-right { left: 200px; clip: rect(235px 335px 345px 160px /* non-standard syntax, but supported by all major browsers*/ }

<p class="dotted-border"> <img src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Original graphic"> <img id="top-left" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to upper left"> <img id="middle" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped towards middle"> <img id="bottom-right" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to bottom right"> </p>

规格

SpecificationStatusComment
CSS Masking Module Level 1The definition of 'clip' in that specification.Candidate RecommendationDeprecates clip property, suggests clip-path as replacement.
CSS TransitionsThe definition of 'clip' in that specification.Working DraftDefines clip as animatable.
CSS Level 2 (Revision 1)The definition of 'clip' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0(Yes)1.0 (1.0)4.017.01.0 (85)1

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support?(Yes)????