我想根據下面的圖片繪製4個div。CSS div佈局定位
但相反我得到這個。
下面是我的HTML。包裝div的位置設置爲相對,並將包含的div設置爲絕對。但是,它們全都堆疊在一起。謝謝。
\t #container{
\t \t \t \t position: relative;
\t \t \t }
\t \t \t .blocks{
\t \t \t \t width: 200px;
\t \t \t \t height: 100px;
\t \t \t \t border: 1px solid black;
\t \t \t \t text-align: center;
\t \t \t }
\t \t \t #1{
\t \t \t \t position: absolute;
\t \t \t \t margin: auto auto;
\t \t \t }
\t \t \t #2{
\t \t \t \t position: absolute;
\t \t \t \t float: left;
\t \t \t }
\t \t \t #3{
\t \t \t \t position: absolute;
\t \t \t \t float: right;
\t \t \t }
\t \t \t #4{
\t \t \t \t position: absolute;
\t \t \t \t margin: auto auto;
\t \t \t \t bottom: 20px;
\t \t \t }
<!DOCTYPE html>
<html>
\t <head>
<title></title>
<meta charset="utf-8">
</head>
\t <body>
<div id="container">
\t \t <div class="blocks" id="1">1</div>
\t \t <div class="blocks" id="2">2</div>
\t \t <div class="blocks" id="3">3</div>
\t \t <div class="blocks" id="4">4</div>
</div>
\t </body>
</html>
錯字:汽車音響;' – j08691
感謝j08691。我糾正了它。 – martinbshp