Mobile Upload unknown image size, JS set width and height ratio

Source: Internet
Author: User

<style rel= "stylesheet" type= "Text/css" >

. lunboimg{width:100%; height:auto; float:left;}
. lunboimg img{width:100%; float:left;}

</style>

$ (function () {
var evt = "onorientationchange" in window? "Orientationchange": "Resize";
Window.addeventlistener (evt, function () {
Location.reload ()
}, False); When the screen is rotated, refresh the page, (prevent the image from getting the width fixed, the picture cannot be adapted)

var width =$ (window). width (); Get the width and height of your phone browser
var height=$ (window). Height ();
height=width*0.5; Picture height = 0.2 aspect ratio of picture width: 2:1
$ ("#banner"). CSS ({"width": width, "height": height}); Get the scaled size
});

<div class= "Lunboimg" >

</div>

Mobile Upload unknown image size, JS set width and height ratio

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.