Home  >  Article  >  Web Front-end  >  [学习笔记]viewport定义,弹性布局,响应式布局_html/css_WEB-ITnose

[学习笔记]viewport定义,弹性布局,响应式布局_html/css_WEB-ITnose

PHP中文网
PHP中文网Original
2016-06-24 11:22:041112browse

一,移动端宽度设置
viewport视图窗口,7b839031155f08eaf08474101d920ec7,视窗宽度=设备宽度,默认缩放=1,不允许用户缩放。

二,flexbox,弹性盒子模型:
1,在元素的css中添加display:-webkit-flex就可以转换成弹性盒模型了,然后在多个子元素的CSS中添加flex:1/2/3,就可以让子元素按定义的比例1/2/3分配填满父元素。
2,混合划分:

1224.png

子元素可以是固定宽度,也可以是定义flex值,灵活运用,常见于

1225.png

图片采用固定宽度防止缩放失真,然后右边的文字采用弹性布局设置flex:1。
3,不定宽高的水平、垂直居中

CSS3方案:

.myoff-wrapper{
position:absolute;
top:50%;
left:50%;
z-index:3;
-webkit-transform:translate(-50%,-50%);
border-radius:6px;
background:#fff;
}

更好的flexbox方案:设置父元素,让子元素水平居中

.parent{
display:-webkit-flex;
justify-content:center;//子元素水平居中
align-items:center;//子元素垂直居中
}

更多应用:

1226.png

三,响应式布局:在不同设备不同分辨率下都有良好的用户体验

1227.png

响应式布局方法是依靠媒体查询实现的:

1228.png

媒体查询类型:screen(屏幕)、print(打印机)、handheld(手持设备)、all(通用)
常用媒体查询参数:width,height,device-width,device-height,orientation(检查设备处于横向lanscape还是竖屏portrait)


em:根据父元素的font-size为相对单位;
rem:根据html的font-size为相对单位。

1229.png


1230.png

以上就是[学习笔记]viewport定义,弹性布局,响应式布局_html/css_WEB-ITnose的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn