简单的css问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 20:36:26
有四个div,其中一个(图中黑色的)包含另外三个(图中红色),然后样式如图,黑色div内部有两个在顶部多出一点,怎么实现?谢谢

采用负margin,演示如下 ,支持窗口缩放,你用的时候需要去掉height,或者修改,看实际情况了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
body{margin:0;padding:0;}
#container{margin-top:40px;padding:.5em;border:1px solid #000;color:#fff;font:24px sans-serif;}
#side-first{float: left;}
#side-second{float: right;}
#content{margin: 0 210px;background:#9c3;height:460px;}
#side-first,
#side-second{margin-top:-40px;width:200px;height:500px;background:#6cf;}
</style>
</head>
<body>