• 关于垂直居中


    table 方式

    .parent {
        display: table-cell;
    vertical-align: middle; } .child { margin: auto; }

    translate + 绝对定位:

    .parent {
        position: relative;
    }
    .child {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    绝对定位+四个方向置0

    .parent{
        width: 200px;
        height: 200px;
        position: relative;
    }
    .child{
        width: 100px;
        height: 100px;
        margin: auto;  
        position: absolute;  
        top: 0; 
        left: 0; 
        bottom: 0; 
        right: 0; 
    }

     ::after + inline-block :

    .parent{
        /***/
    }
    .parent::after{
        content: '';
        width: 0;
        height: 100%;
        display: inline-block;
        vertical-align: middle;
    }
    .child{
        display: inline-block;
    }

    flex 布局

    .parent {
        display: flex;
        align-items: center;
    }
    .child {
        /**/
    }

    ---- 移动端 文字在容器内垂直居中  安卓 line-height 不居中----

    传统写法是 令 line-height 与 height 相等即可,但是在安卓浏览器里文字会偏上,无法居中。网上大神分析原因大致是 Android 对文字的渲染高度不同。我们可以采取 flex 的方式来解决

    display: flex;
    align-items: center;

    待续。。。

  • 相关阅读:
    CentOS7安装注意
    ES插件安装
    CentOS7命令
    ES安装手册
    五 、redis-cluster java api
    四 、Redis 集群的搭建
    三 redis 的 java api(jedis)
    C#验证码 使用GDI绘制验证码
    云时代架构阅读笔记二——Java性能优化(二)
    【转载】Asp .Net Web Api路由路径问题
  • 原文地址:https://www.cnblogs.com/_error/p/10209958.html
Copyright © 2020-2023  润新知