viewport

响应式布局

∥☆過路亽.° 提交于 2020-01-09 08:20:28
Viewport:是用户网页的可视区域。 手机浏览器是把页面放在一个虚拟的"窗口"(viewport)中,通常这个虚拟的"窗口"(viewport)比屏幕宽,这样就不用把每个网页挤到很小的窗口中(这样会破坏没有针对手机浏览器优化的网页的布局),用户可以通过平移和缩放来看网页的不同部分。 设置 Viewport 一个常用的针对移动网页优化过的页面的 viewport meta 标签大致如下: width:控制 viewport 的大小,可以指定的一个值,如果 600,或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的像素)。 height:和 width 相对应,指定高度。 initial-scale:初始缩放比例,也即是当页面第一次 load 的时候缩放比例。 maximum-scale:允许用户缩放到的最大比例。 minimum-scale:允许用户缩放到的最小比例。 user-scalable:用户是否可以手动缩放。 响应式网格视图 创建响应式网格视图 接下来我们来创建一个响应式网格视图。 首先确保所有的 HTML 元素都有 box-sizing 属性且设置为 border-box 。 确保边距和边框包含在元素的宽度和高度间。 添加如下代码: * { box-sizing: border-box; 来源: https://www

bootstrap响应式布局原理

岁酱吖の 提交于 2020-01-09 03:02:10
来源于:https://blog.csdn.net/qq_21794603/article/details/68585249 Bootstrap响应式布局是利用其栅格系统,对于不同的屏幕采用不同的类数据。在开发中可以只写一套代码在手机,平板,PC端都能使用,二不用考虑使用媒体查询(针对不同的设备分别写不同的代码)。Bootstrap的官方解释:Bootstrap提供了一套响应式、移动设备优先的流逝栅格系统,随着屏幕或者视口(viewport)尺寸的增加,系统会自动分为最多12列。 栅格系统用于通过一系列的行(row)与列(column)的组合来创建页面布局; 栅格系统的工作原理: 1、行(row)必须包含在.container(固定宽度)或者.container-fluid(100%宽度)中,一遍为其赋予合适的排列(aligment)和内部(padding); 2、通过行(row)在水平方向创建一组列(column); 3、自己内容应当放置与类(column)内,并且只有列可以作为行(row)的直接子元素。 4、类似.row和col-xs-4这种预定义的类,可以用来快速创建栅格布局。Bootstrap源码中定义的mixin也可以用来创建语义化布局。 5、通过为列设置padding属性,从而创建列与列直接的间隔(gutter)。通过为.row元素设置负值margin从而抵消为

前端页面自适应

て烟熏妆下的殇ゞ 提交于 2020-01-08 12:26:56
前端页面自适应 <meta name= "viewport" content= "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 页面的头部加上这句话. <meta name= "viewport" content= "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 页面的头部加上这句话. 来源: https://www.cnblogs.com/xdlzs/p/12165773.html

移动Web开发-WebApp(flex布局+移动端导航案例)

浪尽此生 提交于 2020-01-07 12:29:57
实际开发中的像素:css像素 设备像素比dpr=设备像素/css像素 标清屏dpr=1 高清屏dpr=2 缩放改变的是css像素大小 PPI(每英寸的物理像素点)=根号(屏幕横向分辨率²+屏幕纵向分辨率²)/屏幕对角线长度(单位英寸) 视口viewport <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, maximum-scale=1, minimum-scale=1"> <script> console.log(window.innerWidth);//窗口文档显示区宽度 console.log(document.documentElement.clientWidth);//浏览器窗口文档显示区域的宽度,不包括滚动条 console.log(document.documentElement.getBoundingClientRect().width);//这个方法返回一个矩形对象,包含四个属性:left、top、right和bottom。分别表示元素各边与页面上边和左边的距离 // getBoundingClientRect().top // getBoundingClientRect().right // getBoundingClientRect()

Show div at top of page, hide when scrolling, then show div at bottom of page

不羁的心 提交于 2020-01-07 05:02:12
问题 When a user is at the top of a page, the div is shown. When they scroll down the page, the div is hidden until they reach the bottom of the page, whereby the div is shown again. The div would be a fixed navigation menu Below is some code posted by another member, which successfully shows the div at the bottom of the page, but always hides it at the top. Original post can be found here: How to show div when user reach bottom of the page? Thanks! <script> $(document).ready(function() { $(window

Dynamic viewport resizing - Phonegap ignores viewport

感情迁移 提交于 2020-01-07 04:26:08
问题 I'm using the following code to "resize my app to the screen size of the device showing it: $(function() { if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { var ww = ( $(window).width() < window.screen.width ) ? $(window).width() : window.screen.width; //get proper width var mw = 600; // min width of site var ratio = ww / mw; //calculate ratio if( ww < mw){ //smaller than minimum size $('#vp').attr('content', 'initial-scale=' + ratio + '; maximum-scale=' + ratio +

Add class to div when in viewport

匆匆过客 提交于 2020-01-07 03:59:10
问题 I want to add a class to a menu item when a different div enters the viewport. I have successfully replicated the alert found here: http://jsfiddle.net/blowsie/M2RzU/ However, when I try to change it from an alert to an addClass or toggleClass it breaks. This is my code: $('#portfolio').bind('inview', function (event, visible) { if (visible == true) { // element is now visible in the viewport $( "#menu-item-portfolio" ).addClass( ".active-area" ); } else { // element has gone out of viewport

Trigger function when element is visible on screen (viewport)

半城伤御伤魂 提交于 2020-01-07 02:55:08
问题 jQuery has the plugin appear or waypoint to detect if element is visible or not in viewport. I did some research, I can not find and wonder if Angular2 has a similar plugin. If not yet, what is the best way to do something like that? 回答1: This is how I do it: sync-dom.utils.ts static isInViewPort(rect: ClientRect, threshold = 0) { return rect && rect.height && rect.top + rect.height + threshold >= 0 && rect.left + rect.width + threshold >= 0 && rect.bottom - rect.height - threshold <=

Viewport Checker - jQuery run loop once

微笑、不失礼 提交于 2020-01-06 20:16:48
问题 I am using viewport checker and I want the animation to only run once, so far I have the following:- jQuery('#style-wrapper').viewportChecker({ callbackFunction: function(elem) { var flag = true; interval = setInterval(function(){ jQuery('.page-template-template-homepage .work-description').html('Different'); jQuery('.page-template-template-homepage .work-description').css( "font-weight", "700" ); jQuery('.page-template-template-homepage #style-wrapper').css( "background", "#7ec4bf"); jQuery(

Is there a way to prevent viewport resizing due to ui elements like url bar?

微笑、不失礼 提交于 2020-01-06 19:37:45
问题 My problem is that I am making a responsive website and want the viewport to be always fullscreen eg on document ready I want the body to be 100% of the available device window INCLUDING the height for the url bar and other navigation elements like those on ios, and for it to stay that way. The resizing is breaking my percentage based design. I have included the following for the viewport: <meta name="viewport" content="width=device-width, height=device-height, maximum-scale=1.0, minimum