日期:2014-05-17  浏览次数:20708 次

一个大的难题~~~样式的难题~~~我发现想不出来解决方法
HTML code
<!DOCTYPE html>
    <head>
        <style>
#wrapper{width:800px;position:absolute;left:50%;margin-left: -400px;height:300px;border:1px solid red}
    </style>
    <body>
        <div id="wrapper"></div>
    </body>
</html>



网页呈现的是一个div居中,

现在要做的是,【紧接着】这个div,要在它下面加一个div,

比如<div>123</div>

紧接着的含义是,在id为wrapper的div正下方,左端距离一样,顶部接上面的div

发现相当难~~~~

------解决方案--------------------
HTML code

<!doctype html>
<html>
<head>
<style>
* {padding:0px;margin:0px;}
body {background:#ccc;}
#page {width:802px;margin-left:auto;margin-right:auto;margin-top:10px;}
#wrapper1 {width:800px;height:300px;border:1px solid red;background:white;}
#wrapper2 {width:800px;height:300px;border:1px solid blue;background:white;}
</style>
</head>
<body>
<div id="page">
<div id="wrapper1">div1</div>
<div id="wrapper2">div2</div>
</div>
</body>
</html>

------解决方案--------------------
<!DOCTYPE html>
<head>
<style>
#wrapper{width:800px;margin-left:400px;height:300px;border:1px solid red;}
</style>
<body>
<div id="wrapper"></div>
<div id="wrapper">123</div>
</body>
</html>

给分 完美解决
------解决方案--------------------
<!DOCTYPE html>
<head>
<style>
#wrapper{width:800px;position:absolute;left:50%;margin-left: -400px;height:300px;border:1px solid red;}
</style>
<body>
<div id="wrapper"></div>
<div style="width:800px;position:absolute;left:50%;margin-left: -400px;height:300px;border:1px solid red;top:310px">123</div>

</body>
</html>
------解决方案--------------------
这样不行么???
<div style="width:800px;position:absolute;left:50%; top:200px; margin-left: -400px;height:300px;border:1px solid red">
assdf
<div style="position:absolute; left:0px; bottom:-100px; width:100px; height:100px; border:#0F0 1px solid;">1234</div>
</div>