CSS在绝对块中剪切图像

时间:2015-06-12 16:27:09

标签: html css

我试图用绝对块剪切图像。我想隐藏右图像(红线)左列高度。

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>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

你的意思是这样的: https://jsfiddle.net/82ov0e3t/28/

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

答案 1 :(得分:0)

要在左侧图像的高度剪切右侧图像,请在窗口加载和窗口调整大小时使用此js。

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

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