ios - Mobile Website - Viewport depending on device-width -
i have mobile website , little problem viewport meta tag in -part.
my code:
<meta id="testviewport" name="viewport" content="width=640">
it working fine on iphone 4s on ipad 2, doesn't work properly. want viewport set width of users hardware. there way achieve or have read out model type , set viewport switch or if code?
thanks in advance.
niels
edit:
here's css. want achieve: let site displayed in device-width. if display-size smaller 640px, should change viewport 640px. not working on ios 7.0, safari:
@viewport { width: device-width; } @media screen , (max-device-width: 640px) { @viewport { width: 640px; } }
edit#2:
fixed using js in of index.html:
<meta id="viewport" name="viewport" content="width=device-width" /> <script> if (window.innerwidth < 640){ var vp = document.getelementbyid('viewport'); vp.setattribute('content', 'width=640'); } </script>
instead of setting content="width=640"
try 1 <meta name="viewport" content="width=device-width">
update:
to serve high-res images / change zooming retina devices css use this:
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { /* retina-specific stuff here */ }
Comments
Post a Comment