CSS-几种元素居中方式
来源:互联网 发布:c语言文件打开错误 编辑:程序博客网 时间:2024/05/17 22:01
margin
table居中
利用伸缩盒居中
margin居中
<div style="width: 100px; height: 100px; margin: 0 auto; background-color: greenyellow;"> 居中</div>
table居中
适用于文字居中,还有line-height ;
<!--css--> .box1{ width: 100px; height: 100px; background-color: aquamarine; display: table; } .box2{ display: table-cell; vertical-align: middle; text-align: center; }<!--html--><div class="box1"> <p class="box2">居中</p></div>
利用伸缩盒居中
flex-box,以Chrome为例,设置Chrome内核的弹性盒子
<!--css--> .outter{ width: 200px; height: 200px; background-color: gold; display: -webkit-box; -webkit-box-align: center; -webkit-box-pack: center; } .inner{ width: 100px; height: 100px; background-color: aqua; display: -webkit-box; -webkit-box-align: center; -webkit-box-pack: center; }<!--html--><div class="outter"> <div class="inner"> 居中 </div></div>
阅读全文
0 0
- CSS-几种元素居中方式
- CSS几种居中方式
- css垂直居中的几种方式
- CSS中的几种居中方式整理
- css中的几种图片居中方式
- 【笔试题】阿里内推---CSS实现元素居中的几种方式
- css几种方法使元素水平垂直居中
- CSS元素水平居中常用的几种方法
- css控制元素垂直居中的几种方法
- 用CSS实现居中的几种方式
- html里元素水平居中和垂直居中的几种方式
- CSS设置元素水平居中、垂直居中方式汇总
- CSS中元素隐藏的几种方式
- CSS隐藏一个元素的几种方式及其不同
- 元素居中的几种方法
- 页面元素居中的几种方法
- 元素居中的几种方法
- 元素居中屏幕的几种方法
- Codeforces Round #453 (Div. 2) ABCD题解
- 【Spring Cloud】--客户端负载均衡Spring Cloud Ribbon
- 一些帮助类:CommonUtils,,,,OkHttp3Util
- Springboot idea中实现热部署
- SpringMVC在Controller层中注入request的坑
- CSS-几种元素居中方式
- Java解析xml文件和html文件
- 有关C语言的知识---宏定义用法
- pandas读取csv编码问题
- win10 开启telnet服务
- 使用Java创建RESTful Web Service
- Visual Assist X_10.9.2238.2_Cracked
- cocos2d-x中DrawNode常见的图像绘制函数
- 18. PHP bcompiler