div/css居中页面不变尺寸

1、项目目录:

 

2、test.html

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <link href="css/style.css" type="text/css" rel="stylesheet" />
    <link href="css/customfont.css" type="text/css" rel="stylesheet"/>
    <script src="js/jquery-3.1.1.slim.js"></script>
</head>
<body class="backbround">
    <div class="all-div">
        <div class="navigation-list">
            <div class="navigation-list-title">
                <img src="img/navigation-title.jpg" style="margin: 55px">
            </div>
            <div class="navigation-list-column">
                <p class="navigation-list-font">Page1</p>
            </div>
            <div class="navigation-list-column">
                <p class="navigation-list-font">Page2</p>
            </div>
            <div class="navigation-list-column">
                <p class="navigation-list-font">Page3</p>
            </div>
            <div class="navigation-list-column">
                <p class="navigation-list-font">Page4</p>
            </div>
        </div>
        <div class="auto-resize-left"></div>
        <div class="navigation-div"></div>
        <div class="auto-resize-right"></div>
    </div>
    <script>
        $(".navigation-list").css("width",document.body.scrollWidth+"px");
        $(".backbround").css("height",screen.height+"px");
        $(".all-div").css("width",document.body.scrollWidth+"px")
        $(".navigation-div").css("width",document.body.scrollWidth-300+"px");
    </script>
</body>
</html>

 

 

 

 

 

3、customfont.css

 

.navigation-list-font {
    height: 30px;
    text-align: center;
    font-size: 20px;
    font-weight: bolder;
    color: darkorange;
    margin: 60px;
    padding: 10px;
}

 

 

 

 

 

4、style.css

 

.backbround {
    background-image: url('../img/driver.png');
    background-attachment:fixed;
    background-repeat:no-repeat;
    background-size:cover;
    -moz-background-size:cover;
    -webkit-background-size:cover;
    margin:0;
    padding:0;
    height: 2000px;
}

.all-div {
    height: 2000px;
}

.auto-resize-left {
    width: 150px;
    height: 2000px;
    float: left;
}

.auto-resize-right {
    width: 150px;
    height: 2000px;
    float: right;
}

.navigation-div {
    height: 2000px;
    float: left;
}

.navigation-list {
    height:170px;
    background-color: black;
    filter:alpha(opacity=40);
    -moz-opacity:0.4;
    -khtml-opacity: 0.4;
    opacity: 0.4;
}

.navigation-list-title {
    width: 30%;
    height: 170px;
    background-color: black;
    float: left;
}

.navigation-list-column {
    width: 15%;
    height: 170px;
    background-color: black;
    float: left;
}

 

 

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值