課程
/前端開發
/HTML/CSS
/網頁布局基礎
兩個浮動的div寬度加起來沒有超過960,怎么會在只設置左浮動的時候兩個div不能并排顯示?
2016-12-07
源自:網頁布局基礎 3-3
正在回答
圖片在這里
Amaranta
qq_銜尾蛇_0 回復 Amaranta
我打代碼試了下,確實沒有并排
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="utf-8">
? ? <title></title>
</head>
<style>
? ? * {
? ? ? ? margin: 0;
? ? ? ? padding: 0;
? ? }
? ? #warp {
? ? ? ? margin: 5px auto;
? ? ? ? width: 960px;
? ? #header {
? ? ? ? background-color: grey;
? ? #body {
? ? ? ? background-color: yellow;
? ? #footer {
? ? ? ? background-color: blue;
? ? .left {
? ? ? ? background-color: red;
? ? ? ? float: left;
? ? ? ? width: 500px;
? ? .right {
? ? ? ? background-color: green;
? ? ? ? width: 350px;
</style>
<body>
? ? <div id="warp">
? ? ? ? <div id="header">header
? ? ? ? </div>
? ? ? ? <div id="body">body
? ? ? ? ? ? <div class="left">
? ? ? ? ? ? ? ? left
? ? ? ? ? ? </div>
? ? ? ? ? ? <div class="right">
? ? ? ? ? ? ? ? right
? ? ? ? <div id="footer">
? ? ? ? ? ? footer
? ? </div>
</body>
</html>
</div>
<div id="footer">
qq_銜尾蛇_0
qq_銜尾蛇_0 回復 qq_銜尾蛇_0
兩個div的浮動都要設置
上代碼
舉報
讓你精通CSS中三大定位機制,徹底掌握網頁布局的相關知識
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-02-18
圖片在這里
2017-02-18
我打代碼試了下,確實沒有并排
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="utf-8">
? ? <title></title>
</head>
<style>
? ? * {
? ? ? ? margin: 0;
? ? ? ? padding: 0;
? ? }
? ? #warp {
? ? ? ? margin: 5px auto;
? ? ? ? width: 960px;
? ? }
? ? #header {
? ? ? ? background-color: grey;
? ? }
? ? #body {
? ? ? ? background-color: yellow;
? ? }
? ? #footer {
? ? ? ? background-color: blue;
? ? }
? ? .left {
? ? ? ? background-color: red;
? ? ? ? float: left;
? ? ? ? width: 500px;
? ? }
? ? .right {
? ? ? ? background-color: green;
? ? ? ? width: 350px;
? ? }
</style>
<body>
? ? <div id="warp">
? ? ? ? <div id="header">header
? ? ? ? </div>
? ? ? ? <div id="body">body
? ? ? ? ? ? <div class="left">
? ? ? ? ? ? ? ? left
? ? ? ? ? ? </div>
? ? ? ? ? ? <div class="right">
? ? ? ? ? ? ? ? right
? ? ? ? ? ? </div>
? ? ? ? </div>
? ? ? ? <div id="footer">
? ? ? ? ? ? footer
? ? ? ? </div>
? ? </div>
</body>
</html>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
2016-12-07
兩個div的浮動都要設置
2016-12-07
上代碼
2016-12-07
上代碼