Clip an image into a specified shape:
document.getElementById("myImg").style.clip = "rect(0px 75px 75px 0px)";
Try it Yourself »
The clip property sets or returns which part of a positioned element is visible.
Property | |||||
---|---|---|---|---|---|
clip | Yes | Yes | Yes | Yes | Yes |
Return the clip property:
object.style.clip
Set the clip property:
object.style.clip = "auto|rect(
top right bottom left)|initial|inherit"
Value | Description |
---|---|
auto | Default. The element does not clip |
rect(top right bottom left) | Clips the shape defined by the four coordinates |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | auto |
---|---|
Return Value: | A String, representing the part of a positioned element that is visible |
CSS Version | CSS2 |
Return the clip property:
alert(document.getElementById("myImg").style.clip);
Try it Yourself »
CSS tutorial: CSS Positioning
CSS reference: clip property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!