让容器中设置为浮动的元素垂直居中:

在父元素上进行设置:

<style type="text/css">
    #demo {
        width: 300px;
        height: 200px;
        background-color: grey;

        display: table-cell;
        vertical-align: middle;
    }
        .fl {

            float: left;
            width: 50px;
            height: 50px;
            background-color: black;

        }
    </style>
</head>
<body>
    <div >
        <div class="fl"></div>
    </div>
</body>

 

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2021-10-25
  • 2022-02-20
  • 2022-01-28
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案