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>

.

css3实现水平垂直居中------(特别注意,里边的固定还是不固定)的更多相关文章

  1. css3实现水平垂直居中

    1.transform实现居中(未设宽高) <div id="wrap">内容</div> <style> #wrap{ padding:50p ...

  2. css3种不知道宽高的情况下水平垂直居中的方法

    第一种:display:table-cell 组合使用display:table-cell和vertical-align.text-align,使父元素内的所有行内元素水平垂直居中(内部div设置di ...

  3. CSS3中flexbox如何实现水平垂直居中和三列等高布局

    最近这些天都在弥补css以及css3的基础知识,在打开网页的时候,发现了火狐默认首页上有这样一个东西.

  4. 用CSS/CSS3 实现水平居中和垂直居中,水平垂直居中的方式

    一.水平居中 (1)行内元素解决方案:父为块元素+text-align: center 只需要把行内元素包裹在一个属性display为block的父层元素中,并且把父层元素添加如下属性即可: 使用te ...

  5. 水平垂直居中div(css3)

    一.在需要居中的元素加上如下C3属性即可: <!doctype html><html lang="en"><head> <meta cha ...

  6. css3 flex 详解,可以实现div内容水平垂直居中

    先说一下flex一系列属性: 一.flex-direction: (元素排列方向) ※ flex-direction:row (横向从左到右排列==左对齐) ※ flex-direction:row- ...

  7. css3不定宽高水平垂直居中

    1 justify-content:center;//子元素水平居中 2 align-items:center;//子元素垂直居中 3 display:-webkit-flex; 在父级元素上面加上上 ...

  8. CSS3/CSS之居中解析(水平+垂直居中、水平居中,垂直居中)

    首先,我们来看下垂直居中: (1).如果是单行文本,则可以设置的line-height的数值,让其等于父级元素的高度! <!DOCTYPE html> <html lang=&quo ...

  9. css3水平垂直居中(不知道宽高同样适用)

    css水平垂直居中 第一种方法: 在父div里加: display: table-cell; vertical-align: middle; text-align: center; 内部div设置: ...

随机推荐

  1. PcAnywhere用法

    安装软件 配置被控端 点击"主机",点击"添加" 可以使用"现有的Windows账户",也可以创建新的"用户名和密码" ...

  2. Celery:Monitor

    参考文档:http://docs.celeryproject.org/en/latest/userguide/monitoring.html#guide-monitoring

  3. win2008r2 32位odbc安装笔记

    这ORACLE也太难用了,想简单点了事只用个ODBC CLIENT都是件麻烦事,总结了一下,安装流程如下: 1.去官网或其它地方下载: 64位: instantclient-basic-windows ...

  4. Python的插件化开发概述

    Python的插件化开发概述 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.插件化开发 动态导入: 运行时,根据用户需求(提供字符串),找到模块的资源动态加载起来. 1> ...

  5. git track remot

    echo "# test" >> README.md git init git add README.md git commit -m "first comm ...

  6. 调试中行支付demo

    用eclipse调试中行支付demo,本来报错. 让我同学帮我远程看了下,他删了服务器,又添加服务器,然后竟然可以运行了,牛逼! 原来报错: at java.net.URLClassLoader$1. ...

  7. KMP算法的时间复杂度与next数组分析

    一.什么是 KMP 算法 KMP 算法是一种改进的字符串匹配算法,用于判断一个字符串是否是另一个字符串的子串 二.KMP 算法的时间复杂度 O(m+n) 三.Next 数组 - KMP 算法的核心 K ...

  8. LeetCode 931. Minimum Falling Path Sum

    原题链接在这里:https://leetcode.com/problems/minimum-falling-path-sum/ 题目: Given a square array of integers ...

  9. Tensorflow细节-P319-使用GPU基本的操作

    如果什么都不加,直接运行装了GPU的Tensorflow,结果是这样子的 import tensorflow as tf a = tf.constant([1.0, 2.0, 3.0], shape= ...

  10. Window IDEA开发工具 杀死指定端口 cmd 命令行 taskkill

    Windows平台   两步方法 :  1 查询端口占用,2 强行杀死进程 netstat -aon|findstr "8080" taskkill /pid 4136-t -f ...