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>

  • 相关阅读:
    物流与仓库
    测试使用
    禅修的升级
    《引爆点 马尔科姆 格拉德威尔》读书笔记总结----《创业必读书第20本》--创业第三关做好业务:3,如何做好营销和增长第4本
    shell
    Vue中常用的方法记录
    前端工程化3-tapable
    Browser上传文件到华为云/七牛云 详细步骤
    immutable
    shell利用叮叮发送消息
  • 原文地址:https://www.cnblogs.com/lxsunny/p/12717930.html
Copyright © 2011-2022 走看看