我有两个 div,一个在另一个里面。“innerdiv”没有像我预期的那样表现。它不在右侧的“maindiv”内部。有人会解释为什么吗?
JsFiddle:http: //jsfiddle.net/D9RsQ/
这是我的html:
<!DOCTYPE html>
<head>
<meta charset = "UTF-8"/>
<title>Home</title>
<link rel="stylesheet" text="text/css" href="css.css">
</head>
<body>
<div class = "maindiv">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
</p>
<div class = "innerdiv">
<p>This is innerdiv content</p>
</div>
</div>
</body>
这是我的CSS:
html {
height:100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat:no-repeat;
background: -webkit-linear-gradient(#ffffff, #004c99);
background: -moz-linear-gradient(#ffffff, #004c99);
background: -ms-linear-gradient(#ffffff, #004c99);
background: -o-linear-gradient(#ffffff, #004c99);
background: linear-gradient(#ffffff, #004c99);
}
p {
font-family:"Arial Black";
line-height:120%;
}
div.maindiv {
width:90%;
margin-top:0px;
margin-left:auto;
margin-right:auto;
margin-bottom:0px;
padding:0px;
background-color:rgb(220,220,220);
border-right: solid black 2px;
border-left: solid black 2px;
}
div.innerdiv {
width:100px;
float:right;
background-color:rgb(100,100,100);
}