简体   繁体   English

如何使子图像比父div大并放置在任何位置

[英]How to have a child image be larger then a parent div and be positioned anywhere

I have a parent container div with display: inline-block . 我有一个带display: inline-block的父容器div display: inline-block This allows me to adjust the image height using % values. 这使我可以使用%值来调整图像高度。 I can't adjust the width beyond 100% though which I need. 尽管我需要调整宽度,但不能超过100%。

How in css/html can I setup a parent div and child image so that I can use % values to scale the image larger then the parent and position the image top and left with % values? 如何在css / html中设置parent divchild image以便可以使用%值将图像缩放到比父图像更大,并使用%值在图像的顶部和左侧定位?

for example: 例如:

div {
    width:  50%; 
}
img {
    width: 150%;
    margin-right: -50%;
}

JSFIDDLE 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM