Css 实现遮罩层

<!doctype html>
<html>
<head>
    <title>布局实例</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <style>
        #zhezhao{
            /*典型的遮罩层做法*/
            width:100%;
            height:100%;
            position:fixed;
            background:black;
            opacity:0.3;
            z-index:100;
            display:none;
        }
        #login{
            /*border:1px solid red;*/
            width:300px;
            height:80px;
            /*居中做法*/
            position:absolute;
            left:50%;
            top:50%;
            margin-left:-150px;
            margin-top:-40px;
            background:#ccc;
            z-index:101;
            display:none;
        }
    </style>
</head>
<body>
    <div id="zhezhao"></div>
    <div id="zhezhao"></div>
    <div id="login">
        <form action="1.php">
            用户名:<input type="text" /><br>
            密 码:<input type="password" /><br>
            <input type="submit" value="登录" />
            <button type="button" onclick="zhezhao.style.display='none';login.style.display='none'">取消</button>
        </form>
    </div>

    <div class="container">
        <!-- 头部开始 -->
        <div class="header">
            <div class="header-top">
                <div class="left bg logo">LOGO</div>
                <div class="left bg banner1">BANNER1</div>
                <div class="left bg banner2" onclick="zhezhao.style.display='block';login.style.display='block'">登录</div>
            </div>
            <div class="clear"></div>
            <div class="nav bg">菜单</div>
        </div>
        <!-- 头部结束 -->
        <!-- 主体开始 -->
        <div class="main">
            <div class="main-left left">
                <div>
                    <div class="big left">栏目一</div>
                    <div class="big right">栏目二</div>
                </div>
                <div>
                    <div class="small left" style="margin-left:0px">栏目三</div>
                    <div class="small left">栏目四</div>
                    <div class="small left">栏目五</div>
                    <div class="small left">栏目六</div>
                </div>
            </div>
             <div class="main-right right">
                <div class="aside">栏目七</div>
                <div class="aside" style="margin:10px 0">栏目八</div>
                <div class="aside">栏目九</div>
            </div>
        </div>
        <!-- 主体结束 -->
        <div class="clear"></div>
        <div class="footer bg">页脚</div>
    </div>
</body>
</html>

###style.css

/*预定义样式*/
body,ul,p,h1,h2,h3,h4,h5,h6{margin:0;padding:0;}
body{text-align:center;}
.left{float:left;}
.right{float:right;}
.clear{clear:both;}
.bg{background:#ccc;}

/*内容开始*/
.container{
    width:960px;
    margin:0 auto;
    /*border:1px solid red;*/
    overflow:hidden;
}

/* 头部开始 */
.logo{
    width:200px;
    height:80px;
}
.banner1{
    width:540px;
    height:80px;
    margin:0 10px;
}
.banner2{
    width:200px;
    height:80px;
}
.nav{
    height:30px;
    margin:10px 0;
}
/* 头部结束 */

/* 主体开始 */
.main-left{
    width:750px;
}
.main-left .big{
    width:368px;
    height:198px;
    border:1px solid #ccc;
}
.main-left .small{
    width:178px;
    height:198px;
    border:1px solid #ccc;
    margin-left:10px;
    margin-top:10px;
}
.main-right .aside{
    width:198px;
    height:128px;
    border:1px solid #ccc;
}
/* 主体结束 */
/* 尾巴开始 */
.footer{
    height:50px;
    margin-top:10px;
}
/* 尾巴结束 */
/*内容结束*/

转载于:https://my.oschina.net/phpweishunlong/blog/889737

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值