I'm writing a simple forum that should show images. I need to display by default only a part of image (default width and default height). I need users to be able to resize the size of this window. So when user enlarges the window, more of the image should fit into it. Scrolling should be available too (i found about scrolling -- Scroll full image inside div
but it doesnt allow to change window size. How to do it? Thanks
js:
imgUrl= document.getElementById("view_topic").getAttribute( "data-url" );
$('.img-wrapper').append($('<img id="theImg">').attr({
'src': imgUrl , //'https://' + imgUrl ,
'alt': 'test image'
})
).scrollTop(9999)
css:
.img-wrapper {
overflow: auto;
height: 200px;
background-color: blue;
position: relative;
overflow-x:auto;
overflow-y:auto;
}
.img-wrapper > img {
display: block;
height: auto;
width: 100%;
position: absolute;
/*top: -50%;*/
vertical-align: top;
}
html:
<html>
<div id="myDiv" class="img-wrapper">
</div>
</html>