【css】div盒子垂直居中

<head>
    <meta charset="UTF-8">
    <title>canvas_learn</title>
    <style>
        #canvas {
            box-shadow: 2px 2px 2px 2px #888888;
            position: absolute;//绝对定位
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;//垂直居中
        }
    </style>
</head>
<body>
    <canvas id="canvas" height="600" width="700">helloha!!!</canvas>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/m0_67986791/article/details/129022826