flex上下、左右居中
tip:1)flex是用于div布局用的,作用于一级子元素(父元素写样式,作用于子元素)
2)弹性盒模型
3)英文解释justify-content: 对齐内容(内容一般写在主轴上)align-items:对齐子所有项目(子项目用于侧轴)
<template>
<div class="test">
<div class="header">头部</div>
<div class="body">内容
<div class="left">左侧</div>
<div class="right">右侧</div>
</div>
<div class="footer">尾部</div>
</div>
</template>
<style lang="scss">
.test {
border: 1px solid red;
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */ display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: flex; /* 新版本语法: Opera 12.1, Firefox 22+ */
justify-content: center; //主轴方向,默认水平方向
align-items: center; // 交叉轴方向,默认垂直方向
.header{
width: 100px;
height: 100px;
border: 1px solid green;
}
.body{
width: 200px;
height: 200px;
border: 1px solid blue;
// display: flex;
// justify-content: center;
// align-items: center;
div{
width: 50px;
height: 50px;
border: 1px solid yellow;
}
}
.footer{
width: 300px;
height: 300px;
border: 1px solid black;
}
}
</style>

flex上下、左右居中的更多相关文章
- flex布局居中无效果注意是否设置了宽度
<View style={{display:),backgroundColor:),alignItems:'center'}}> <JDTouchable style={styles ...
- 页面常见布局以及实现方法--flex
页面布局是前端工程师的基本功之一,总结分析各种布局实现方法,可以让自己快速定位哪种方法实现功能,同时可以做到现最大程度的兼容. 一.水平居中 假设:最基本机构 .parent>.child 1. ...
- css居中那些事
一.css垂直居中 1.line-height(适用于单行文本居中) eg: html:<p class="wordp">123</p>- css: .w ...
- DIV水平方向居中的几种方法
一.使用margin: 1 #center0 { 2 background: red; 3 margin: 0 auto; 4 } 或者: margin: auto; 这样的前提是父盒子里没有其他盒子 ...
- css高度居中
1.已知元素高度 // 子盒子 #div1{ width:200px; height:200px; position: absolute; //父元素需要相对定位 top: 50%; left: 50 ...
- day07——css布局解决方案之居中布局
转行学开发,代码100天——2018-03-23 1.水平居中 使用inline-block + text-align方法 先将子框由块级元素改为行内块元素,再通过设置行内块元素居中以实现水平居中 ...
- CSS3之flex布局
若要使用flex布局,需在父元素上声明" display : flex ",这样它所有的直系子元素就成为flex元素 1.居中 1)垂直居中:align-items : cente ...
- flex布局个人总结
<html> <div class="box1"> <span>1</span> <span>2</span> ...
- 我已经说了5种css居中实现的方式了,面试官竟然说还不够?
这是一篇关于居中对齐方式的总结 开篇之前,先问一下大家都知道几种居中的实现方式? 面试时答出来两三个就不错了,就怕面试官还让你继续说.今天就来总结一下这些居中的方式 使用flex布局设置居中. 使用f ...
- css-文字和图片在容器内垂直居中实测。方法来源张鑫旭博客。
方法一:在文字或者图片后加入一个width为0的inline-block元素,将文字inline-block后vertical-align:middle.图片同理 多行文字居中:(有些浏览器会出问题, ...
随机推荐
- pandas中的quantile函数
https://blog.csdn.net/weixin_38617311/article/details/87893168 data.price.quantile([0.25,0.5,0.75]) ...
- processing模拟三角级数合成方波过程
代码 1: int radius = 2; 2: int[] accumys; 3: int times = 0; 4: 5: float scale = 1; 6: int origin = 400 ...
- 前端面试题,js预处理部分小结,函数声明提升和变量声明提升
博客搬迁,给你带来的不便,敬请谅解! http://www.suanliutudousi.com/2017/11/25/%e5%89%8d%e7%ab%af%e9%9d%a2%e8%af%95%e9% ...
- CentOS 7 安装 nginx1.15
1,安装依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel SSL功能需要openssl库 gzip模块需要z ...
- 解决HDFS小文件带来的计算问题
hive优化 一.小文件简述 1.1. HDFS上什么是小文件? HDFS存储文件时的最小单元叫做Block,Hadoop1.x时期Block大小为64MB,Hadoop2.x时期Block大小为12 ...
- Spring项目下js文件无法引用
问题:最近练习spring-mvc框架的时候,引用了jQuery,但是运行的时候,jQuery做的事情都没有响应,代码也没有任何报错,在网上找了一下,发现是由于spring配制的是/,所有的资源都被屏 ...
- maven spring-mvc mybatis整合
一 首先在myeclipse中安装好maven插件. 1.下载地址:http://mirror.bit.edu.cn/apache/maven/maven-3/3.0.5/binaries/apach ...
- nginx信号及平滑升级
1.nginx信号 nginx进程处理命令: kill -signals PID PID即nginx进程ID signals的参数解释如下所示: TERM,INT快速关闭进程 QUIT优雅的关闭,如果 ...
- JDBC getConnection细节
https://blog.csdn.net/luanlouis/article/details/29850811 概述 一般情况下,在应用程序中进行数据库连接,调用JDBC接口 ...
- Exist/In 使用
exists表示()内子查询语句返回结果不为空说明where条件成立就会执行主sql语句,如果为空就表示where条件不成立,sql语句就 不会执行.not exists和exists相反,子查询语句 ...