当前位置:网站首页>移动布局(flex布局、视口标签)
移动布局(flex布局、视口标签)
2022-04-23 06:26:00 【GuTaiWEI】
记录一下自己学习的内容,欢迎大家评论与指正。
视口标签
语法格式
// 默认
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
// 标准
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
viewport:视口
width=device-width
:视口宽度 = 设备宽度initial-scale=1.0
:初始页面缩放倍数maximum-scale=1.0
最大缩放倍数user-scalable=0
不允许用户缩放页面(移动端) 或者为 no 如果为 yes 则允许用户缩放
百分比布局(流式布局)
效果: 宽度自适应,高度固定。
flex布局/弹性布局
作用: 基于 Flex 精确灵活控制块级盒子的布局方式,避免浮动布局中脱离文档流现象发生。Flex布局非常适合结构化布
格式:
display:flex;
flex-direction
flex-direction
: 属性决定主轴的方向(即项目的排列方向)
.box { flex-direction: row | row-reverse | column | column-reverse; }
- row(默认值):主轴为水平方向,起点在左端。
- row-reverse:主轴为水平方向,起点在右端。
- column:主轴为垂直方向,起点在上沿。
- column-reverse:主轴为垂直方向,起点在下沿。
flex-wrap
flex-wrap
:设置容器中的项目是否换行,默认情况下,项目都排在一条线上。
.box{ flex-wrap: nowrap | wrap | wrap-reverse; }
- nowrap(默认):不换行。
- wrap:换行,第一行在上方。
- wrap-reverse:换行,第一行在下方。
flex-flow
flex-flow
:属性是 flex-direction
属性和flex-wrap
属性的简写形式,默认值为 row nowrap
。
.box { flex-flow: flex-direction flex-wrap; }
justify-content
justify-content
:属性定义了项目在主轴上的对齐方式。
.box { justify-content: flex-start | flex-end | center | space-between | space-around; }
- flex-start(默认值):左对齐
- flex-end:右对齐
- center: 居中
- space-between:两端对齐,项目之间的间隔都相等。
- space-around:每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。
- space-evenly:项目之间的间隔与项目与边框的间隔相等。
align-items
align-items
:属性定义项目在交叉轴上如何对齐。
.box { align-items: flex-start | flex-end | center | baseline | stretch; }
- flex-start:交叉轴的起点对齐。
- flex-end:交叉轴的终点对齐。
- center:交叉轴的中点对齐。
- baseline: 项目的第一行文字的基线对齐。
- stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。
align-content
align-content
:属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用,属性值基本与justify-content
相同 。
.box { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }
- flex-start:与交叉轴的起点对齐。
- flex-end:与交叉轴的终点对齐。
- center:与交叉轴的中点对齐。
- space-between:与交叉轴两端对齐,轴线之间的间隔平均分布。
- space-around:每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍。
- stretch(默认值):轴线占满整个交叉轴。
伸缩比
属性:flex : 整数;
flex:1;
效果:将整个flex容器剩余空间分为几分,再将其分给项目。
- 只占用父盒子剩余尺寸
- 是给子盒子添加这个属性
版权声明
本文为[GuTaiWEI]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_43826202/article/details/124333408
边栏推荐
- F-牛妹的苹果树(直径合并)
- 技能点挖坑
- Redis connection error err auth < password > called without any password configured for the default user
- 反思|开启B站少女心模式,探究APP换肤机制的设计与实现
- keytool: command not found
- SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
- js之节点操作,为什么要学习节点操作
- Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
- BTree、B+Tree和HASH索引
- Ogldev reading notes
猜你喜欢
随机推荐
Solutions to common problems in visualization (VII) solutions to drawing scale setting
[hdu6833]A Very Easy Math Problem(莫比乌斯反演)
Hot change scheme and dynamic update strategy of mobile game
SAP pi / PO rfc2soap publishes RFC interface as WS example
【自我激励系列】你永远不会准备好
Reflect on the limitations of event bus and the design and implementation of communication mechanism in component development process
数据库查询优化的方式
Common DOS commands
SAP PI/PO rfc2Soap 发布rfc接口为ws示例
P1446 [HNOI2008]Cards(Burnside定理+dp计数)
BTree、B+Tree和HASH索引
SAP PI/PO登录使用及基本功能简介
配置npm
反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
6. Aggregation function and grouping statistics
[Ted series] how does a habit change my life
promise all的实现
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
js之函数的两种声明方式
Mvcc (multi version concurrency control)