【发布时间】:2018-02-22 17:26:33
【问题描述】:
我将此图像附加到 div JSFiddle 我的 Div 在模态框内。我尝试默认显示左下角(如填充 div)并允许用户水平和垂直滚动以查看图像的其余部分,但似乎我有一些蓝色区域,我无法滚动直到图像的结尾。
imgUrl = "nerdist.com/wp-content/uploads/2018/02/year-or-the-tank-girl-header.jpg"
$('.img-wrapper').append($('<img id="theImg">').attr({
'src': 'https://' + imgUrl ,
'alt': 'test image'
})
)
.img-wrapper {
overflow: hidden;
height: 400px;
background-color: blue;
position: relative;
overflow-x:auto;
overflow-y:auto;
}
.img-wrapper > img {
display: inline-block;
height: 150%;
width: 150%;
position: relative;
top: -50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="myDiv" class="img-wrapper">
</div>
有没有办法在模式打开时显示图像的左下四分之一并允许用户滚动 XY 以查看其余部分?
我是 HTML 编程新手,所以请温柔:)
【问题讨论】:
标签: javascript jquery html css