首页 > 代码库 > fixed定位对其

fixed定位对其

fixed定位

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>fixed</title>
    <style type="text/css">
    .div1{
        position: fixed;
        left: 100%;
        top: 50%;
        margin-left: -200px;/*向左移动一个DIV的宽度就可以显示了的*/
        margin-top: -100px;
        width: 200px;
        height: 200px;
        border: 1px solid blue;
        background: pink;
        z-index: 999;
    }
    .div2{
        margin: 0 auto;
        width: 500px;
        height: 1000px;
        border: 1px solid blue;
        background: silver;

    }
    </style>
</head>
<body>
    <div class="div1">
        11111111111111111111
    </div>
    <div class="div2"></div>
</body>
</html>

 

<style>.div1 { position: fixed; left: 100%; top: 50%; margin-left: -200px; margin-top: -100px; width: 200px; height: 200px; border: 1px solid blue; background: pink; z-index: 999 } .div2 { margin: 0 auto; width: 500px; height: 1000px; border: 1px solid blue; background: silver }</style>
11111111111111111111
 

fixed定位对其