Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct using of mobile viewport on different devices with small width

I have such css code for mobile devices:

@media all and (min-width: 0px) and (max-width: 991px) {...}

and i have such html:

<meta name="viewport" content="width=1024, initial-scale=1" id="viewportMt">

<script>
  window.onload = function () {
    if(screen.width < 970) {
      var vp = document.getElementById('viewportMt');
      vp.setAttribute('content','width=640, initial-scale=1');
    }
  }
</script>

the main problem, is that when i firstly open my website: on most of devices i have to scale my browser view to fit it...

is it possible to fit device automatically? for example if device width is 340: i should scale it out a little bit (because website is to big for 340px (it;s min.640px))... If 900: then scale too...

even ipad (in portrait mode, because it's width is 768px).

is it possible to do?

plunker:

https://plnkr.co/edit/5KhIlmtLkWhtROs7y188?p=preview

and demo:

enter image description here

why i have there scrollbar? i need somehow to zoom it out, so that i will not have any scrollbar there... and my container should be 640px and no other values for mobile devices...

like image 766
brabertaser19 Avatar asked Dec 21 '15 08:12

brabertaser19


People also ask

What is the minimum width of the viewport display in pixels?

Bootstrap primarily uses these media query ranges to create sensible breakpoints. will be applied to only the devices whose viewport width is minimum 576 px wide and not be more than 767 px. The same logic applies for medium, large, extra large devices respectively.

What is the maximum width for mobile view?

Mobile (Smartphone) max-width: 480px. Low Resolution Tablets and ipads max-width: 767px. Tablets Ipads portrait mode max-width:1024px.

How we can use width of viewport?

Setting The ViewportThe width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device). The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

What size should I design for mobile?

16:9 is most popular aspect ratio, due to its considerable width, this format is considered panoramic. In other words, it captures a wider area than other aspect ratios.


2 Answers

Use the HTML5 zoom property as seen below. This will zoom the body to + or -. Any value can be used.

<body style="zoom:50%;">
like image 136
Sagar V Avatar answered Oct 21 '22 02:10

Sagar V


This is what I use for all my responsive web apps.

<meta name="viewport" content="width=device-width, initial-scale=1">
like image 34
Jeff Diederiks Avatar answered Oct 21 '22 02:10

Jeff Diederiks