zoukankan      html  css  js  c++  java
  • 盒子居中的几种方法

    <!DOCTYPE html>
    <html lang="zh">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    </head>
    <style type="text/css">
    *{
    margin:0;
    padding:0;
    list-style: none;
    }
    .box{
    height: 400px;
    400px;
    border: #000000 1px solid;
    background-color: aqua;
    box-sizing: border-box;
    /* 第八种 */


    /* 第一种方法
    display: flex;
    justify-content: center;
    align-items: center; */

    position: relative;
    margin:100px auto;
    }
    .box .inbox{
    height: 100px;
    display: inline-block;
    100px;
    border: 1px solid #C81623;
    box-sizing: border-box;
    background-color: #C81623;

    position: absolute;
    /* 第二种 */
    /* left: 50%;
    top: 50%;
    margin-left: -50px;
    margin-top:-50px; */

    /* 第三种 */
    /* left:200px;
    top:200px;
    margin-top: -50px;
    margin-left: -50px; */

    /* 第四种 */
    /* left: 50%;
    top: 50%;
    transform: translate(-50px,-50px); */

    /* 第五种 */
    /* left: 50%;
    top: 50%;
    transform: translate(-50%,-50%); */

    /* di六种 */
    /* left:200px;
    top:200px;
    transform: translate(-50%,-50%); */

    /* 第七种 */
    /* left: 0;
    top:0;
    right: 0;
    bottom: 0;
    margin: auto; */






    }
    /* 8种 */
    .one{
    200px;
    height: 60px;
    line-height: 60px;
    margin: 0 auto;
    background-color: #00FFFF;
    text-align: center;
    }


    </style>
    <body>
    <!-- <div class="box">
    <div class="inbox"></div>
    </div> -->

    <div class="one">
    <span>中华人民共和国</span>
    </div>
    </body>
    </html>

  • 相关阅读:
    云原生技术实践,起步k8s
    线程,同步构造
    线程,限制的异步操作
    DotNet Core管道通信
    打下设计模式
    739--Daily Temperatures
    1021--RemoveOutermostParentheses
    Java并行程序基础。
    155--MinStack
    1047--Remove All Adjacent Duplicates In String
  • 原文地址:https://www.cnblogs.com/lxsunny/p/12717930.html
Copyright © 2011-2022 走看看