Search code examples
htmlcssclip

Clip Property CSS values


After trying a gruesome lot of time I am still not gaining the correct co-ordinates or pixels to clip/crop out my image

the image:

https://i.sstatic.net/y4L2T.jpg

I want to clip out the right and left white portion of the image.Thanks.


Solution

  • Is this what your wanting? The clip property does NOT CHANGE THE IMAGE SIZE!

    img {    
        position: absolute;
        clip: rect(58px 416px 532px 184px);
    }
    body {
      background-color: #000;
    }
    <img src="https://i.sstatic.net/y4L2T.jpg">

    I really think this is what you want:

    div {
        position: relative;
        height: 475px;
        width: 234px;
        overflow: hidden;
    }
    img {    
        position: absolute;
        left: -183px;
        top: -58px;
    }
    <div>
    <img src="https://i.sstatic.net/y4L2T.jpg">
    </div>