[英]Why wont my divs float?
為什么我的div不會浮動? Content1和Content2應該並排放置。 我想念什么? 我相信這很簡單。 我顯然很早就參與了這個項目,因此無需更正所有其他問題:)。
這是我的CSS:
body {
margin: 0;
background-color: #cccccc;
}
#header {
width: 100%;
height:90px;
background-color: #999999;
}
#container {
margin-right: 20%;
margin-left: 20%;
width: 1000px;
}
#content1 {
width: 300px;
float: left;
}
#content2 {
width: 405px;
float: left;
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:90px;
background-color: #999999;
}
這是我的html:
<div id="header">
My Personal Page
</div>
<div id="container">
<div id="Content1">
<img src="http://localhost:8888/portrait.png" height="400">
</div>
<div id="Content2">
<img src="http://localhost:8888/portrait.png" height="400">
</div>
</div>
<div id="footer">
Copyright Information
</div>
因為您輸入的id's
錯誤。
ID的名稱必須與CSS表中的名稱完全相同。 在html中, Content1
帶有大寫字母C,而在CSS中, content1
帶有小寫字母c 。
這你有同樣的場景Content2
(HTML)和content2
(CSS)。
您的html :( 錯誤)
<div id="Content1"> && <div id="Content2">
新的html :( 右)
<div id="content1"> && <div id="content2">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.