Cut CSS image in absolute block

I am trying to cut an image with an absolute block. I want to hide the correct image with the (red line) left column height.

Jsfiddle

.relative {
    position: relative;
}

.box {
    position: relative;  
}

.border {
    border: 1px solid red;
}

.inside {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;      
}
<div class="container">
    <div class="row border">
        <div class="col-xs-4">
            <img src="http://lorempixel.com/300/500/nature/" class="img-responsive"/>
        </div>
        <div class="col-xs-8 relative">
            <div class="box">
                <div class="inside">
                    <img src="http://lorempixel.com/800/1000/nature/" class="img-responsive"/>
                </div>
            </div>
        </div>
    </div>    
</div>
Run codeHide result
+4
source share
2 answers

You mean something like this: https://jsfiddle.net/82ov0e3t/28/

.border{ bordeR: 1px solid red; overflow: hidden;}
+2
source

To crop the correct image to the height of the left image, use this js in loading the window and resizing the window.

$('.inside').css({
  'height': $('.border').outerHeight(),
  'overflow': 'hidden'
});

https://jsfiddle.net/afelixj/82ov0e3t/29/

0
source

All Articles