代碼
提交代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 清除默認(rèn)樣式 */
* { padding: 0; margin: 0; }
/* 令html和body全屏顯示, 并有一個(gè)灰色背景 */
html, body { height: 100%; background: gray; }
/* 在父元素上設(shè)置相對定位 */
body { position: relative; }
div {
/* 絕對定位 */
position: absolute;
/* 令其上下方向與父元素的距離為0 */
top: 0;
bottom: 0;
/* 白色背景 */
background: white;
}
/* 左邊的列 */
.left {
/* 令其左側(cè)方向與父元素的距離為2% */
left: 2%;
/* 令其右側(cè)方向與父元素的距離為51% */
right: 51%;
}
/* 右邊的列 */
.right {
/* 令其左側(cè)方向與父元素的距離為51% */
left: 51%;
/* 令其右側(cè)方向與父元素的距離為2% */
right: 2%;
}
</style>
</head>
<body>
<div class="left"></div>
<div class="right"></div>
</body>
</html>
運(yùn)行結(jié)果