
批改狀態(tài):合格
老師批語:
以圣杯布局為例
通過外邊距的負(fù)值和絕對定位修改左右邊欄的位置,把內(nèi)容區(qū)擠在中間
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>圣杯布局</title>
<link rel="stylesheet" href="shengbei.css" />
</head>
<body>
<div class="container">
<div class="main">
消息:關(guān)心海洋、認(rèn)識海洋、經(jīng)略海洋!中國經(jīng)濟(jì)的騰飛,與海洋密不可分。黨的十八大以來,習(xí)近平總書記高度重視海洋工作,關(guān)心海洋事業(yè)發(fā)展。在中國航海日之際,央視網(wǎng)系列創(chuàng)意微視頻《非凡十年》,邀您一起來看中國航海的奮進(jìn)之路。
</div>
<div class="left">左</div>
<div class="right">右</div>
</div>
</body>
</html>
/* CSS文件 */
.container {
width: 1000px;
min-height: 600px;
overflow: hidden;
margin: auto;
padding: 0 200px;
position:relative;
}
.main,
.left,
.right {
float: left;
min-height: 600px;
}
.main {
width: 100%;
background-color: coral;
}
.left {
width: 200px;
margin-left: -100%;
background-color: yellow;
position: absolute;
left: -200px;
}
.right {
width: 200px;
margin-left: -200px;
background-color: yellow;
position: absolute;
right: -200px;
}
把二維碼放在網(wǎng)頁的右側(cè)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>圣杯布局</title>
<link rel="stylesheet" href="shengbei.css" />
</head>
<body>
<div class="container">
<div class="main">
消息:關(guān)心海洋、認(rèn)識海洋、經(jīng)略海洋!中國經(jīng)濟(jì)的騰飛,與海洋密不可分。黨的十八大以來,習(xí)近平總書記高度重視海洋工作,關(guān)心海洋事業(yè)發(fā)展。在中國航海日之際,央視網(wǎng)系列創(chuàng)意微視頻《非凡十年》,邀您一起來看中國航海的奮進(jìn)之路。
</div>
<div class="left">左</div>
<div class="right">右</div>
</div>
<div class="qr"><img src="dy.png" alt="douyin" /></div>
</body>
</html>
/* CSS文件 */
.container {
width: 600px;
min-height: 600px;
overflow: hidden;
margin: auto;
padding: 0 200px;
}
.main,
.left,
.right {
float: left;
min-height: 600px;
}
.main {
width: 100%;
background-color: coral;
}
.left {
width: 200px;
margin-left: -100%;
background-color: yellow;
position: relative;
left: -200px;
}
.right {
width: 200px;
margin-left: -200px;
background-color: yellow;
position: relative;
right: -200px;
}
.qr img {
width: 100px;
}
.qr {
position: fixed;
right: 0;
top: 400px;
}
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號