我想隐藏子对象的某些部分,以便父容器之外的所有内容都不可见(因此我的部分图片应根据容器的高度进行裁剪)
我遵循了很多论坛的答案,告诉我把容器放到相对位置(我的必须是相对的,所以这不是问题)
.img-container {
margin : auto;
overflow:hidden;
width:250px;
position: relative;
height: 250px;
border : 5px dotted gray;
}
.img-container object, .img-container img{
position : absolute;
display: inline-block;
}
.img1{
top : 0px;
left : 0px;
width:60%;
}
.img2{
width: 52%;
left :120px;
top:50px;
}
<div class="img-container">
<object class='img1' data='https://svgshare.com/i/6Pz.svg'>
</object>
<object class='img2' data='https://svgshare.com/i/6Pz.svg'>
</object>
</div>
https://jsfiddle.net/u0upm3j3/2/
答复:
好吧好吧。。。我不明白的是:它现在起作用了。
我做了什么?除了重新启动Chrome,什么都没有。
感谢D3nj、Cavdi的回答,感谢Creaforge和Daniel的评论,很抱歉让您浪费了一点时间。但真的,我不明白它现在和以前是如何工作的。。。
pos中的示例运行良好。