CSS Div固定在网页顶部、底部、左侧、右侧

本文介绍了如何使用CSS将Div元素固定在网页的顶部、底部、左侧及右侧的方法。通过设置position为fixed并指定top、bottom、left和right的属性值,可以实现Div元素在网页中的固定位置布局。

  Div固定在网页顶部

.header {
    width:100%;
    height:80px;
    background-color:#FAFAFA;
    position:fixed; 
    top:0;
    left:0;
    z-index:99;
}

 

  Div固定在网页底部

.footer {
    width:100%;
    height:50px;
    line-height:50px;
    background-color:#3394c7;
    position:fixed;
    bottom:0px;
    left:0px;
}

 

  Div固定在网页左侧

.leftNav {
    height:auto;
    background-color:#333;
    position:fixed;
    z-index:2;
    left:0px;
    top:80px;
    bottom:50px;
}

 

  Div固定在网页右侧

.rightNav {
    height:auto;
    background-color:#333;
    position:fixed;
    z-index:2;
    rigth:0px;
    top:80px;
    bottom:50px;
}

 

先这样。以后遇到再说吧。

 

转载于:https://www.cnblogs.com/xjyj/p/3740850.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值