zoukankan      html  css  js  c++  java
  • css多行文本垂直居中

    方法1 ; 父级设行高 子级inline-block 重新设置行高    

    <style> * { margin: 0; padding: 0; list-style: none; } body { background-color: #94fcff; } .wrap{ height: 300px; background-color: #ffbc9a; line-height: 300px; } .box { background-color: red; display: inline-block; vertical-align: middle; line-height: 30px; } </style> </head> <body> <div class="wrap"> <div class="box"> 我是浮动的盒子 我要居中 我是浮动的盒子 我要居中我是浮动的盒子 我要居中我是浮动的盒子 我要居中 我是浮动的盒子 我要居中我是浮动的盒子
    我要居中 我是浮动的盒子 我要居中我是浮动的盒子 我要居中 我是浮动的盒子 我要居中
    </div> </div>

    方法2 子级与父级高度一致

    .wrap{
                height: 300px;
                background-color: #fff;
    
            }
            .box {
                display: table-cell;
                vertical-align: middle;
                height: 300px;
            }

    方法3 flew

    .box {
                display: flex;
                align-items: center;
                height: 300px;
            }

    其他定位相关的方法就不写了相信很容易找到

  • 相关阅读:
    DC中为什么要用Uniquify?
    hdu 1596 find the safest road
    hdu2112 HDU Today
    hdu 2066 一个人的旅行
    poj 3026 Borg Maze
    poj 1979 Red and Black
    poj 1321 棋盘问题
    hdu 1010 Tempter of the Bone
    hdu 4861 Couple doubi
    codeforces584B Kolya and Tanya
  • 原文地址:https://www.cnblogs.com/aqigogogo/p/8028160.html
Copyright © 2011-2022 走看看