看看我這個錯哪了, 為什么左和右放到中間就出問題,單獨放一個就沒事
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>混合布局</title>
<style>
body{margin: 0;padding: 0;font-size: 20px;font-weight:bold}
div{text-align: center;line-height: 30px}
.top{height: 100px;background: blue}
.main{width: 800px;height: 300px;background: red;margin: 0 auto}
.left{width: 300px;height: 300px;background: yellow;float: left}
.right{width: 500px;height: 300px;background: #369;float: right}
.foot{height: 100px;background: #900;margin: 0 auto}
</style>
</head>
<body>
<div class="top">top</div>
<div class="main">main
<div class="left">left</div>
<div class="right">right</div>
</div>
<div class="foot">foot</div>
</div>
</body>
</html>
2022-03-27
謝謝鼓勵。Android程序里必定有onCreate方法,不會沒有的
2016-04-04
<div class="main"> main??這main是內(nèi)容了,單獨要成一個塊,覆蓋不了!
2016-03-10
<div class="main">main把最右main刪除就行了
2016-03-10
首先,我覺得你想得好像復(fù)雜了一些。,其實他要求完成什么就寫什么就行了。。你的main設(shè)置margin: 0 auto,他左右自動了,然后你的left又是左浮動,所以main就變成了left的右邊來了,
main我把他想作是一個背景,所以只設(shè)置和左右側(cè)相同的高度,然后寬度就隨便他變化了。你的top高100px,所以你可以直接給left設(shè)置絕對定位 position:absolute;top:100px;left:0px; ,然后left上面就緊貼top,并也在最左側(cè)了。然后給left設(shè)置一個寬度,例如你的300px,把right的位置用margin-left,這樣就可以將right和left的位置拉開,例如right設(shè)置margin-left:310px,這樣right距離左側(cè)邊緣就是310px,距離left就是10px。
2016-03-10
倒數(shù)第三行,多了一個</div>吧。