我试图将评论div
元素覆盖在主要div
元素上,但不确定以下内容;
- 它是否正确?
- 有没有更好的方法来实现它?
可以在http://jsfiddle.net/fTbP5/找到代码示例
代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type=" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="en-us" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="copyright" content="© 2012" />
<title>sample layout</title>
<base href="" />
<link rel="stylesheet" type="text/css" media="all" href="" />
<style type="text/css" media="all">
* {
margin: 0px;
padding: 0px;
}
body {
background-color: #eeeeee;
font-family: Arial, Verdana, sans-serif;
color: #ffffff;
}
#content {
width: 700px;
margin-top: 10px;
margin-right: auto;
margin-bottom: 10px;
margin-left: auto;
border-width: 1px;
border-color: #ffffff;
border-style: solid;
overflow: auto;
padding-top: 40px;
padding-bottom: 40px;
}
#header {
font-size: 1em;
color: #FFC700;
margin-left: 100px;
margin-bottom: 20px;
}
.main {
float: left;
width: 300px;
height: 300px;
background-color: #00ACED;
margin-left: 100px;
padding: 20px;
position: relative;
}
.comments {
width: 320px;
background-color: black;
position: absolute;
top: 305px;
left: 0px;
padding: 10px;
}
.shoutbox {
float: left;
width: 100px;
height: 100px;
background-color: orange;
margin-left: 50px;
margin-bottom: 20px;
}
.border {
border-width: 15px;
border-color: #ffffff;
border-style: solid;
}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<div id="container">
<div id="content">
<div id="header"><h1>Title</h1></div>
<div class="main border">
Hi {Name}, <br /> Your details are.
<div class="comments">comments</div>
</div>
<div class="shoutbox border">shoutbox1</div>
<div class="shoutbox border">shoutbox2</div>
</div>
</div>
</body>
</html>