viewport

Find the exact height and width of the viewport in a cross-browser way (no Prototype/jQuery)

纵饮孤独 提交于 2019-11-26 12:49:13
I'm trying to find the exact height and width of a browser's viewport, but I suspect that either Mozilla or IE is giving me the wrong number. Here's my method for height: var viewportHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; I haven't started on width yet but I'm guessing it's going to be something similar. Is there a more correct way of getting this information? Ideally, I'd like the solution to work with Safari/Chrome/other browsers as well. You might try this: function getViewport() { var viewPortWidth; var viewPortHeight; // the

Using jQuery To Get Size of Viewport

血红的双手。 提交于 2019-11-26 12:37:51
How do I use jQuery to determine the size of the browser viewport, and to redetect this if the page is resized? I need to make an IFRAME size into this space (coming in a little on each margin). For those who don't know, the browser viewport is not the size of the document/page. It is the visible size of your window before the scroll. To get the width and height of the viewport: var viewportWidth = $(window).width(); var viewportHeight = $(window).height(); resize event of the page: $(window).resize(function() { }); You can try viewport units (CSS3): div { height: 95vh; width: 95vw; } Browser

Can I change the viewport meta tag in mobile safari on the fly?

女生的网名这么多〃 提交于 2019-11-26 12:02:59
I have an AJAX app built for mobile Safari browser that needs to display different types of content. For some content, I need user-scalable=1 and for other ones, I need user-scalable=0 . Is there a way to modify the value of the content attribute without refreshing the page? <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /> I realize this is a little old, but, yes it can be done. Some javascript to get you started: viewport = document.querySelector("meta[name=viewport]"); viewport.setAttribute('content', 'width=device-width, initial

Is the viewport meta tag really necessary?

女生的网名这么多〃 提交于 2019-11-26 11:48:01
I've created a few responsive sites but am rather new to responsive site development. In my CSS 99% of my values are in ems or percentages. I am using media queries (both max-width and max-device-width) to make layout changes. I have not included a viewport meta tag and it works perfectly on iOS, a number of Android phones and tablets that I tested on, and all desktop browsers. Adding a meta tag breaks my site. Am I doing something wrong, or doing something right so that I don't need to include it? I'm confused as to why it seems to be a best practice, as it's breaking my stuff. Am I missing

How to check if an element is in the view of the user with jquery

淺唱寂寞╮ 提交于 2019-11-26 10:59:11
问题 I have a very big draggable div in my window. This div has a smaller window. <div id=\"draggable-area\" style=\"width:500px;height:500px;overflow:hidden\"> <div id=\"draggable\" style=\"width:5000px;height:5000px\"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> .... </ul> </div> </div> How can I know if the li element is visible in the user viewport (I mean really visible, not in the overflow area)? 回答1: have a look at this plugin It give's you the option to do the following

HTML5 Canvas camera/viewport - how to actually do it?

给你一囗甜甜゛ 提交于 2019-11-26 10:06:47
问题 I\'m sure this was solven 1000 times before: I got a canvas in the size of 960*560 and a room in the size of 5000*3000 of which always only 960*560 should be drawn, depending on where the player is. The player should be always in the middle, but when near to borders - then the best view should be calculated). The player can move entirely free with WASD or the arrow keys. And all objects should move themselves - instead of that i move everything else but the player to create the illusion that

jQuery trigger when 2/3s of div are in viewport

↘锁芯ラ 提交于 2019-11-26 09:14:27
问题 I need to change \"active\" menu item on one-page website, when user slide down or up and something like two thirds of div are visible in viewport. I found some jQuery plugins, but all of them was when whole div is viewed. Simply I need to act same like on this page: https://vivaldi.com/ And my page will look something like: http://jsfiddle.net/kwbddvau/2/ html{height:calc(100% - 100px) !important;width:100% !important; margin:0px; padding:0px;} body{height:500% !important;width:100%

Why does vw include the scrollbar as part of the viewport?

爷,独闯天下 提交于 2019-11-26 07:37:27
问题 I\'m trying to build a website that has lots of boxes that are of equal width and height. For example, I have a page that has 2 equal size boxes side by side. The simple solution was to set the width and height to 50vw. This works great until there is a scroll bar. I\'ve Googled around for hours and can\'t understand why on earth vw and vh would include the scrollbars as part of the viewport. Here\'s a sample of my issue HTML <div class=\"container\"> <div class=\"box red\"></div> <div class=

HTML5 移动端 视口的相关问题

一世执手 提交于 2019-11-26 06:44:32
屏幕尺寸、屏幕分辨率、屏幕像素密度 屏幕尺寸: 指屏幕的对角线的长度,单位是英寸,1英寸=2.54厘米。 常见的屏幕尺寸有2.4、2.8、3.5、3.7、4.2、5.0、5.5、6.0等。 屏幕分辨率:(iphone6 750*1334) 指在横纵向上的像素点数,单位是px,1px=1个像素点。一般以纵向像素*横向像素来表示一个手机的分辨率,如1920*1080。(这里的1像素指的是物理设备的1个像素点) 屏幕像素密度/像素密度/屏幕密度: 屏幕上每英寸可以显示的像素点的数量,单位是ppi,即“pixels per inch”的缩写。 屏幕像素密度与屏幕尺寸和屏幕分辨率有关 相同点:1.设备厂商规定的 2.固定的 物理像素,CSS像素 设备像素/物理像素:(分辨率) 买手机的时候会有一个 n x m 的分辨率,那是屏幕的n x m个呈像的点, 一个点(小方格)为一个物理像素。 它是屏幕能显示的最小粒度. 设备像素也被称为物理像素,他是显示设备中一个最微小的物理部件。 每个像素可以根据操作系统设置自己的颜色和亮度。 任何设备的物理像素的数量都是固定的 CSS像素: CSS像素是一个抽象的单位,主要使用在浏览器上,用来精确的度量(确定)Web页面上的内容。 它是为web开发者创造的,在css或者javascript中使用的一个抽象的层 一般情况下,CSS像素被称为与设备无关的像素

关于移动端页面在手机调整字体大小后无法正常显示(已解决)

我们两清 提交于 2019-11-26 06:42:57
关于移动端页面在手机调整字体大小后内容适配的问题,作为新手我也刚好是第一次遇到, 已经完成的移动端页面,正常情况下在手机上的浏览器端和App端都可以正常显示,可当测 试把手机字体调大后,布局就忽然变乱了....盒子里面的内容向内挤了。说实话,刚开始感觉 这种问题应该可以忽略,毕竟字体调大后,又可以调回原来的啊,而且大部分手机都是默认 显示标准字体吧。而且我在移动端的meta标签里已经给viewport容器添加了相应属性值, 也是用rem布局的,还会出现这种错乱的情况,我能怎么办....不过后来想了想,既然你是前 端工程师,搞技术的,就应该要学会解决技术问题啊,所以我还是打开了浏览器,开始动手 我最熟悉的骚操作Ctrl+C、Ctrl+V... 刚开始我在找是不是viewport容器里还有些属性值少添加了。 我自己原来的值是这样的: <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0"> 感觉是正常的,因为已经调整好了设备宽度、默认缩放比、还有禁止用户手动缩放,所以应该没问题,不过我之后 还是多添加了两个属性值: <meta name="viewport" content="width=device-width,initial-scale=1.0,user