码迷,mamicode.com
首页 > 其他好文 > 详细

页面布局实例

时间:2015-06-17 17:56:38      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

实例1

技术分享
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#container {
    position: absolute;
    border: 1px solid blue;
    left: 10px;
    top: 10px;
    right: 10px;
    bottom: 10px;
}
#left {
    position: absolute;
    border: 1px solid red;
    width: 100px;
    left: 0px;
    top: 0px;
    bottom: 0px;
}
#right {
    position: absolute;
    border: 1px solid green;
    right: 0px;
    left: 100px;
    top: 0px;
    bottom: 0px;
}
#hide1 {
    position: absolute;
    border: 1px solid orange;
    width: 10px;
    left: 0px;
    top: 0px;
    bottom: 0px;
}
#main {
    position: absolute;
    border: 1px solid cyan;
    right: 0px;
    left: 10px;
    top: 0px;
    bottom: 0px;
}
#main-bottom {
    position: absolute;
    border: 1px solid purple;
    height: 200px;
    right: 0px;
    left: 0px;
    bottom: 0px;
}
#main-top {
    position: absolute;
    border: 1px solid pink;
    top: 0px;
    right: 0px;
    left: 0px;
    bottom: 200px;
}
#hide2 {
    position: absolute;
    border: 1px solid orange;
    height: 10px;
    left: 0px;
    right: 0px;
    bottom: 0px;
}
</style>
</head>
<body>
<div id="container">
    <div id="left">
    </div>
    <div id="right">
        <div id="hide1">
        </div>
        <div id="main">
            <div id="main-top">
                <div id="hide2">
                </div>
            </div>
            <div id="main-bottom">
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
var hide1 = document.getElementById(hide1);
var left = document.getElementById(left);
var right = document.getElementById(right);
hide1.onclick = function() {
    var interval = setInterval(function() {
            console.log(left.offsetWidth);
            left.style.width = left.offsetWidth - 10 + px;
            right.style.left = left.offsetWidth + px;
            if (left.offsetWidth < 10) clearInterval(interval);
        }, 100);
}
</script>
View Code

 

页面布局实例

标签:

原文地址:http://www.cnblogs.com/feilv/p/4583978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!