a,----定位方式(父元素宽高固定,子元素宽高固定)

<div class="Father">
<div class="children"></div>
</div>
<style lang="scss" scoped>
.Father{
position: relative;
}
.children{
width: 50px;
height: 50px;
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
margin: auto;
}
</style>

b, ----flex布局方式(父元素宽高不固定,子元素宽高不固定)

<div class="Father">
<div class="children"></div>
</div>
<style lang="scss" scoped>
.Father {
border: 1px solid red;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
}
.children {
width: 50px;
height: 50px;
border: 1px solid blue;
}
</style>

c, ----transform方式(父元素宽高不固定,子元素宽高不固定)

 <div class="Father">
<div class="children"></div>
</div>
<style lang="scss" scoped>
.Father {
border: 1px solid red;
height: 100px;
position: relative;
}
.children {
width: 50px;
height: 50px;
border: 1px solid blue;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%); /* 使用css3的transform来实现 */
}
</style>

.

最新文章

  1. Javascript一些实用技巧
  2. Oracle数据块损坏篇之10231内部事件
  3. python3 文件增删查
  4. mysql 的max_connections和max_user_connections 的区别
  5. scala操作符&amp;运行
  6. JAVA RMI例子
  7. storm安装笔记以及提交拓扑任务
  8. 超简单的处理JSON格式和JSON数组格式的String
  9. iscsi 操作备忘
  10. java实现多继承
  11. Swift--控制流与oc不同的地方
  12. C# ftp 图片上传多快好省
  13. 戴建钊 201521123023《Java程序设计》第1周学习总结
  14. 简单的cookie读写封装
  15. 44.1khz 16位比特双声道一分钟的音乐文件占多少硬盘空间?
  16. unity fbx 导出动画
  17. (一):C++分布式实时应用框架----整体介绍
  18. conda 安装多个版本的python
  19. python网络图片爬取存储全代码
  20. ubuntu下hadoop,spark配置

热门文章

  1. Alpha_7
  2. AIX 静默安装11gR2 RAC
  3. 如何在Win7电脑上增加新磁盘分区?
  4. Pthon魔术方法(Magic Methods)-描述器
  5. OpenStack云计算简介
  6. 基于JFinal中搭建wopi协议支撑办法
  7. ADAS 实车道路及场地测试服务
  8. httprunner学习1-环境与登录接口案例
  9. 注解@Transient
  10. flume的sink写入hive表