CLIP
means CLIP, that is, it trims the contents of a box.
.container {clip: rect (top, right, bottom, left);}
where:
• container
is the HTML element whose content will be trimmed;
• clip
is the trim property;
• rect(top , right , bottom , left)
is the function to cut whose parameters are the coordinates for the clipping expressed in CSS measures.
Imagine that you need to cut the highlighted area in the following figure with their coordinates:
InthiscasethecodeCSS
wouldlooklikethis:
.container{clip:rect(40px,150px,260px,80px);
- Where
rect
istheparametersforcroppingtheimage.
Theresultofcroppingthisimageis:
- Notethattheareaoftheimagethatwascroppedremainswithyourspaceinthedocument.
Note:Theclip
propertyonlyworksforfixedorabsolutepositionedelements.Rememberthatinthe mdn documentation has the following statement.
This feature has been removed from Web standards. Although some
browsers can still support it, it is in the process of falling.
Avoid using it and updating existing code if possible; Refer to the
Compatibility Table at the bottom of this page to guide
your decision. Please be aware that this feature may
work at any time.
Use clip-path instead!
Reference: