0
点赞
收藏
分享

微信扫一扫

css固定定位

343d85639154 2022-03-11 阅读 111

请将html模块类为"box"的div元素固定在视口的左上角。

<html>
    <head>
        <meta charset=utf-8>
        <style type="text/css">
            .box {
                width: 100px;
                height: 100px;
                /*补全代码*/
                position: fixed;
                left: 0px;
                top: 0px;
            }
        </style>
    </head>
    <body>
        <div class='box'></div>
    </body>
</html>

position: fixed,生成绝对定位的元素相对于浏览器窗口进行定位。
生成定位类型为绝对定位,通过设置top、left、button、right改变位置/

举报

相关推荐

0 条评论