Blogger Information
Blog 16
fans 1
comment 0
visits 14160
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019年7月5日作业(五) - (遮罩+绝对定位)和固定定位
杜强_上海_315106编程学习
Original
1344 people have browsed it

以下代码为(遮罩+绝对定位)和固定定位的代码演示

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="static/css/style6.css">
    <title>遮罩+绝对定位+固定定位</title>
</head>
<body>
<div class="shade"></div>
<div class="login" ><img src="static/images/login.jpg" alt="登陆框"></div>

<h1>学习固定定位来php中文网</h1>
<div class="ads">
    <button>×</button>
    <h2>php中文网第八期招生</h2>
    <h1>正在进行中......</h1>
</div>

</body>
</html>
body {
    margin: 0;
    background-image: url(../images/php.png);
    background-size: cover;
    background-repeat: no-repeat;
}
.shade {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    opacity: 0.7;
}

.login img {
    width: 380px;
    height: 460px;
}
.login {
    background-color: white;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -190px;
    margin-top: -230px;
}

.ads {
    width: 400px;
    height: 300px;
    background-color: yellow;
    position: fixed;
    right: 0;
    bottom: 0;
}

以下为代码执行结果截图

0705-5.png

总结:学习完(遮罩+绝对定位)和固定定位应该注意以下几点:

1.固定定位是对于body来讲的

2.绝对定位,必须要把块元素脱离文档流后再进行设置

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post