News from the Field
A channel with tips on modern AI development. Join!
101 of 313 menu
◀ ▶

The clip property

The clip property allows cropping an absolutely positioned element, leaving only the specified rectangular area visible. The value is specified using the rect function.

Syntax

selector { clip: rect(top, right, bottom, left) | auto; }

Preparing images

Let's take a nature image that we'll be cropping:

<img src="image.jpg" width="500">

:

Example

Let's crop the image, leaving only the central part visible:

<div class="container"> <img class="image" src="image.jpg"> </div> .container { position: relative; width: 400px; height: 300px; } .image { position: absolute; clip: rect(50px, 350px, 250px, 50px); width: 400px; height: 300px; }

:

See also

  • the clip-path property,
    a modern alternative for cropping elements
  • the mask property,
    which allows applying a mask
  • the position property,
    required for clip to work
  • the overflow property,
    which can also hide parts of content
← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline