简体   繁体   中英

Change Image Size with Its Resized Size Javascript

Originally the image size is 2000 * 2000. However, it does not fit my window screen. Only the top left of the image can be seen. So I resulted to resizing the image through canvas. How can I set its new dimensions as the image size before I crop it? Jcrop still displays the original image size

you shouldn't have to resize or crop your image. just set the width to say 50vw

 img{ width:50vw;}
 <img src='https://via.placeholder.com/2000'>

Use the meta viewport tag in the head, then use a little smaller size for the image:

Html:

<head>
 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

Css:

  img {
  width: 800px;
  height: 800px;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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