viewport

手机网页H5 自适应不同分辨率的屏幕 必学标签meta之viewport

孤人 提交于 2019-12-07 23:32:18
viewport 语法介绍 <meta name="viewport" content=" height = [pixel_value | device-height] , width = [pixel_value | device-width ] , initial-scale = float_value , minimum-scale = float_value , maximum-scale = float_value , user-scalable = [yes | no] , target-densitydpi = [dpi_value | device-dpi | high-dpi | medium-dpi | low-dpi] "/> width 控制 viewport 的大小,可以指定的一个值或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的像素)。 height 和 width 相对应,指定高度。 initial-scale 初始缩放。即页面初始缩放程度。这是一个浮点值,是页面大小的一个乘数。例如,如果你设置初始缩放为“1.0”,那么,web页面在展现的时候就会以target density分辨率的1:1来展现。如果你设置为“2.0”,那么这个页面就会放大为2倍。 maximum-scale 最大缩放

整理H5|web移动前端自适应适配布局解决方案

為{幸葍}努か 提交于 2019-12-07 23:31:49
方案: 固定一个某些宽度,使用一个模式,加上少许的媒体查询方案 使用flexbox解决方案 使用百分比加媒体查询 使用 rem 1. 简单问题简单解决 我觉得有些 web app并一定很复杂,比如拉勾网,你看看它的页面在iphone4,iphone6,ipad下的样子就知道了: 它的页面有一个特点,就是: 顶部与底部的bar不管分辨率怎么变,它的高度和位置都不变 中间每条招聘信息不管分辨率怎么变,招聘公司的图标等信息都位于条目的左边,薪资都位于右边 这种app是一种典型的弹性布局:关键元素高宽和位置都不变,只有容器元素在做伸缩变换。对于这类app,记住一个开发原则就好:文字流式,控件弹性,图片等比缩放。以图描述: 这个规则是一套基本的适配规则,对于这种简单app来说已经足够,同时它也是后面要说的rem布局的基础。另外对于拉勾这种app可能需要额外媒介查询对布局进行调整的就是小屏幕设备。举例来说,因为现在很多设计稿是根据iphone6的尺寸来的,而iphon6设备宽的逻辑的像素是375px,而iphone4的逻辑像素是320个像素,所以如果你根据设计稿做出来的东西,在iphone4里面可能显示不下,比如说拉钩网底部那个下载框,你对比看下就知道了,这是4: 这是6: · 6下面两边的间距比4多很多,说明拉勾对4肯定是做过适配的,从 代码 也可以证实这一点:

Container width not matching viewport width on mobile device

天涯浪子 提交于 2019-12-07 20:52:17
问题 I recoded my site for responsive design and set the HTML viewport, javascript, and CSS for the outer container div as shown below. On mobile browsers (Opera and Firefox) I have the following problem: In portrait mode (only) the page loads correctly but the window allows scrolling to the right where there is a column of blank space outside the page-container. I can pinch zoom out so that I can see the column of space. Setting minimum-scale=1 only prevents the pinch zoom out, but you can still

移动前端开发之viewport的深入理解

淺唱寂寞╮ 提交于 2019-12-07 20:39:14
在移动设备上进行网页的重构或开发,首先得搞明白的就是移动设备上的viewport了,只有明白了viewport的概念以及弄清楚了跟viewport有关的meta标签的使用,才能更好地让我们的网页适配或响应各种不同分辨率的移动设备。 一、viewport的概念 通俗的讲,移动设备上的viewport就是设备的屏幕上能用来显示我们的网页的那一块区域,在具体一点,就是浏览器上(也可能是一个app中的webview)用来显示网页的那部分区域,但viewport又不局限于浏览器可视区域的大小,它可能比浏览器的可视区域要大,也可能比浏览器的可视区域要小。在默认情况下,一般来讲,移动设备上的viewport都是要大于浏览器可视区域的,这是因为考虑到移动设备的分辨率相对于桌面电脑来说都比较小,所以为了能在移动设备上正常显示那些传统的为桌面浏览器设计的网站,移动设备上的浏览器都会把自己默认的viewport设为980px或1024px(也可能是其它值,这个是由设备自己决定的),但带来的后果就是浏览器会出现横向滚动条,因为浏览器可视区域的宽度是比这个默认的viewport的宽度要小的。下图列出了一些设备上浏览器的默认viewport的宽度。 二、css中的1px并不等于设备的1px 在css中我们一般使用px作为单位,在桌面浏览器中css的1个像素往往都是对应着电脑屏幕的1个物理像素

Showing full (desktop view) website on devices with particular viewport (e.g. lower than 320px)?

流过昼夜 提交于 2019-12-07 15:06:34
I've been finishing my work on a fully responsive website (using Bootstrap 3 framework) and recently the client has asked if it would be possible to have a full (desktop) version of the site on smaller devices (for instance, lower than 320px). Since I've never come across such requirements before, I wonder if there's any legal workaround, e.g. putting an additional viewport meta tag in the head, something like this: <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=1024, user-scalable = yes" media="screen and (max-width: 319px)"> If

Position fixed 100% isn't viewport width when a bigger div is present on the page

ぐ巨炮叔叔 提交于 2019-12-07 13:15:53
问题 I have a scenario where I have a fixed page header, which should be 100% of the viewport width, and a bigger element that is around 5000px wide and scrolls underneath the header. There seems to be several problems with mobile browsers not fixing the header and instead displaying a bigger (ratio calculated??) header which scrolls slower on iOS, and suddenly jumps when past the width of the header in terms of scroll position on android. Using 100vw for the header works, but then sometimes the

Height of the iPad Safari viewport

梦想与她 提交于 2019-12-07 11:14:49
问题 The viewport of the iPad is 980 pixels wide. What's the height? In Safari we must add the address and the new taps. What is the height Safari in landscape mode? There is a media query to fit the web to the width - is there a way to fit the web to the height? 回答1: Below are the answers; You are right. The default viewport on both iPhone/iPad is 980px. There is no default viewport height, as such. You can change the width/height using; <meta name="viewport" content="width=device-width, height

jQueryMobile viewport not working in Windows Phone

Deadly 提交于 2019-12-07 10:39:13
问题 I'm testing jQueryMobile in WindowsPhone and the viewport isn't working. 回答1: There is a workaround on this page. <!--[if IE 7]><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /><![endif]--> 来源: https://stackoverflow.com/questions/6229223/jquerymobile-viewport-not-working-in-windows-phone

Why won't my viewport tag properly use device width (no zoom) on most mobile devices?

烈酒焚心 提交于 2019-12-07 10:03:50
问题 UPDATE 03/2019: This Q&A still gets some activity, nearly 5 years my question came up. Please note this problem was due in part to more common irregularities in older mobile devices at THAT time. With today's browsers and devices, fiddling with viewport scalability would be a shoe-horn fix to a bigger problem which is likely a problem in either your CSS or possibly your markup. I've built a dozen responsive sites and have never experienced this problem. Basically, I'm using the meta tag for

@viewport, @media and LESS

最后都变了- 提交于 2019-12-07 05:32:00
问题 I've recently converted some CSS to LESS for use with a .NET application (I am using dotless for .NET, http://www.dotlesscss.org/ to compile the LESS at runtime). The compiler is falling down on these two blocks of code: @viewport { width: device-width; } /* Add a min-width for IE 8 and lower */ @media \0screen\,screen\9 { body { min-width: 960px; } } Just for your reference, the media query above is a hacky way of targeting IE How can I "LESS-ify" these blocks of code? 回答1: In Less >= 1.4.0