繁体   English   中英

为什么我的div不会浮动?

[英]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">

DEMO

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM