博客列表 >4.26号作业绝对定位/固定定位

4.26号作业绝对定位/固定定位

蜗牛是条鱼
蜗牛是条鱼原创
2019年05月04日 23:11:41902浏览

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>0426作业</title>
    <!--<link rel="stylesheet" href="static/css/style8.css">-->
    <style>
        body {
            margin: 0;
            background-color: green;
            /*background-size: cover;*/
        }
        .shade {
            /* 遮罩绝对定位,并自动伸展到整个窗口 */
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;

            /* 将背景设置为纯黑,并通过透明度使背影内容透出来 */
            background-color: black;
            opacity: 0.7;
        }
        .login img {
            height: 460px;
            width: 380px;
        }
        .login {
            position: absolute;
            left: 50%;
            top: 50%;
            width: 200px;
            height: 300px;
            background-color: blanchedalmond;
            margin-left: -100px;
            margin-top: -150px;
            border-radius: 10%;
            color: red;
            line-height: 300px;
            text-align: center;
            box-shadow: 2px 2px 1px #888;
        }

        .ads{
            position: fixed;
            right: 0;
            bottom:0;
            background-color: blanchedalmond;
            border-radius: 30%;
        }
        button {
            position: absolute;
            top:0;
            right: 0;
            margin-right: 5px;
            background: none;
            border: none;
            font-size: 2em;
            color: red;
        }


    </style>
</head>
<body>
<div class="shade"></div>
<div class="login">请在这里登录</div>
<div class="ads">
<p>
    总结:<br>
    1.遮罩的使用,遮罩两个属性值注意 opacity 透明度; 设置一个背景色。<br>
    2.浮动窗口居中需要拉回去。<br>
    <button onclick="this.parentNode.style.display = 'none'">X</button>
</p>
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议