viewport

移动端调试

柔情痞子 提交于 2019-12-03 10:27:05
Plus篇 真机调试 个人还是觉得,真机调试比模拟器调试靠谱的多~因此,各位在使用模拟器调试之后, 务必记得拿真机再调试一次,防止出现问题。 真机调试的几个步骤 1 将代码放置在服务器端,打开wamp实现服务器端的运行 2 将wamp调整为在线模式 3 将手机调整为和PC相同的局域网 4 在开始菜单中,执行“运行”,输入cmd 5 在弹出的框中输入ipconfig,查看相应网络的ip地址 ,ipv4 6 将ip地址输入到手机url地址栏中,实现访问 c) 弄清视口和屏幕的区别。视口是浏览器的内容显示区域,屏幕是设备的物理显示区域。比如视口宽度我们一般用width表示,而屏幕宽度是用device-width来表示。相信做过手机页面的童鞋都经常见过这段代码: <meta name="viewport" content="width=device-width,initial-scale=1.0"> 其中width=device-width就是说把页面宽度设置成和屏幕宽度一样。 rem 相对于根元素的单位不会相对于其他地方 如html{font-size:12px} p{width:50rem} 意思为p的width为 50*12=600PX em相对于父元素的fontsize % 相对于当前元素的直接父元素 px:基于像素的单位.像素是一种有用的单位

viewport of browser from cross-site iframe

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need to find out the browser viewport size from within a cross-domain iframe. The normal method doesn't work because it only gets the viewport of the iframe. If I use top.innerHeight , etc. in a cross-domain situation, I run into security issues. Is there a different property/method I can use? Cross-browser would be ideal, but even getting this on a single browser would be helpful. (I'm trying to find out if my iframe is in view or not.) 转载请标明出处: viewport of browser from cross-site iframe 文章来源: viewport of browser from cross-site

Expand div from center of viewport

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a question before wherein I wanted to expand a div from the center of the body . It works fine not until I encountered this scenario wherein the content of the body is long enough that a scroll bar now shows. Notice on this jsFiddle that when I scroll to a little to the bottom or just halfway then clicked anywhere on the page, the expanded div is displayed at the very top of the page. I know this CSS code below has something to do with it: . growme { background - color : #990000; height : 0 ; width : 0 ; position : absolute

jQuery: Fullscreen “background” image that moves according to mouse position [closed]

做~自己de王妃 提交于 2019-12-03 08:45:31
I am trying implement a full screen background that moves according to the position of the mouse position. So for example, if you were to move the mouse to the top left, the view port would show the top left of the image and the rest of the image that can fit into the view port. In this case, let's say - the screen is 1280 * 960, but the image is 1800 * 1300. I've seen this before, but I can't remember where and I can't think of the term used to describe what I'm trying to achieve. It's not parallax or scrolling background images... Looking for a jQuery plugin and the beginning CSS I'll need

How to destroy / reload the canvas in html 5?

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on an ebook application, I draw each page on canvas using PDF.js , the problem is , when I click on the button and turn to other page, I tried simply render on the same canvas again , but the canvas seems move to a wrong location or wrong size . function renderPage(url) { canvas = document.getElementById('canvas'); ctx = canvas.getContext('2d'); //clearCanvasGrid('canvas'); PDFJS.getDocument(url).then(function (pdf) { // Using promise to fetch the page pdf.getPage(1).then(function(page) { var viewport = page.getViewport(5); /

Center image in HTML viewport (without JavaScript)

北城以北 提交于 2019-12-03 06:10:18
问题 I have an image I'd like to show in a browser such that: If the image is smaller than the browser viewport, the image is centered horizotally and vertically. If the image is larger than the viewport, the image is scaled down to fill as much of the viewport as possible without adjusting the aspect ratio of the image. Again, the image is centered horizotally and vertically. I do not want to use JavaScript ; what's the best/most semantic HTML and CSS to do this? Update I've been asked for

Set DIV height dynamically based on viewport height

假如想象 提交于 2019-12-03 06:06:37
问题 I'm trying to set a div's height to 30% of the viewport height and I would very much like to scale it when the height of the viewport changes. I tried setting min-height: 30%; height:30% but it is not working. I took a look at JQuery's height(); but I just don't know how to get started. Thanks. 回答1: function thirty_pc() { var height = $(window).height(); var thirtypc = (30 * height) / 100; thirtypc = parseInt(thirtypc) + 'px'; $("div").css('height',thirtypc); } $(document).ready(function() {

<HTML/CSS>BFC原理剖析

六眼飞鱼酱① 提交于 2019-12-03 05:31:19
本文讲了BFC的概念是什么; BFC的约束规则;咋样才能触发生成新的BFC;BFC在布局中的应用:防止margin重叠(塌陷,以最大的为准); 清除内部浮动;自适应两(多)栏布局。 1. BFC 是什么? Block fomatting context = block-level box + Formatting Context Box:   Box即盒子模型; block-level box即块级元素 display属性为block, list-item, table的元素,会生成block-level box;并且参与 block fomatting context; inline-level box即行内元素 display 属性为 inline, inline-block, inline-table的元素,会生成inline-level box。并且参与 inline formatting context; Formatting context   Formatting context是W3C CSS2.1规范中的一个概念。它是页面中的一块渲染区域,并且有一套渲染规则,它决定了其子元素将如何定位,以及和其他元素的关系、相互作用。最常见的 Formatting context 有 Block fomatting context (简称BFC)和 Inline

How to set viewport only for iphone or ipad?

ぃ、小莉子 提交于 2019-12-03 05:06:54
问题 I have a website that needs to use 0.3 value for viewport on iphone, but 0.7 for ipad. Is there a way to set viewport for only iphone or ipad? 回答1: Here is one solution... <!-- in head --> <meta id="viewport" name='viewport'> <script> (function(doc) { var viewport = document.getElementById('viewport'); if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) { viewport.setAttribute("content", "initial-scale=0.3"); } else if ( navigator.userAgent.match(/iPad/i) ) {

Gray area visible when switching from portrait to landscape using iOS 7.1 minimal-ui

大城市里の小女人 提交于 2019-12-03 05:06:32
问题 In a web application that I am working on, I tried out iOS 7.1's new minimal-ui feature (see safari fullscreen in iOS 7.1 with minimal-ui meta tag), but I am seeing an issue where an 84px-high gray area appears at the bottom when I switch from portrait to landscape. Also, document.body.scrollTop changes to 64 after switching to landscape. You can see the issue using this "Hello World" web app: http://www.creativepulse.gr/media/blog/2014/20140123-hello-world/example.html When I load the app in