【HTML / CSS】使用position自適應佈局

weixin_33766168發表於2016-11-29

HTML

<div class="wrapper">
    <div class="header"></div>
    <div class="sidebar"></div>
    <div class="content"></div>
</div>

CSS

* {
    margin: 0; 
    padding: 0;
}
body,html {
    height: 100%;
    overflow: hidden;
}
.header,
.sidebar,
.content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
.header {
    height:100px;
    background: #f08a00;
}
.sidebar {
    top: 100px;
    width: 20%;
    background: #c00000;
}
.content {
    top: 100px;
    left: 20%;
    background: #ccc;
}

相關文章