zoukankan      html  css  js  c++  java
  • 怎么让div垂直居中?

    <div class="parent">
      <div class="child"></div>
    </div>



    <!-- 1 --> div.parent { display: flex; justify-content: center; align-items: center; } <!-- 2 --> div.parent { position: relative; } div.child { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } <!-- 3 --> div.parent { display: grid; } div.child { justify-self: center; align-self: center; } <!-- 4 --> div.parent { font-size: 0; text-align: center; &::before { content: ""; display: inline-block; 0; height: 100%; vertical-align: middle; } } div.child { display: inline-block; vertical-align: middle; }
  • 相关阅读:
    作业11
    作业10总结
    作业10
    作业9总结
    作业9
    作业8总结
    作业8
    实验7总结
    实验6总结
    史航第12次作业&总结
  • 原文地址:https://www.cnblogs.com/Hijacku/p/14874699.html
Copyright © 2011-2022 走看看