我想創建一個僅用於實驗目的的三列布局,但是當我嘗試讓這些列內聯時,它們之間會出現一個間隙,這些間距將顯示在我已鏈接的Codepen中。爲什麼在我嘗試創建的這些列之間存在間距?
我想完成這個只是使用百分比值,而不使用像flex一樣的東西,有什麼,我失蹤?
Codepen鏈接:http://codepen.io/benrichi/pen/MJgOze
HTML
<head>
<title>Column Exercise</title>
</head>
<body>
<div id="col1"> COLUMN 1 CONTENT TO BE PLACED HERE</div>
<div id="col2"> COLUMN 2 CONTENT TO BE PLACED HERE </div>
<div id="col3"> COLUMN 3 CONTENT TO BE PLACED HERE</div>
<div id="footer"> FOOTER CONTENT TO BE PLACED HERE</div>
</body>
</html>
CSS
#col1 {
background-color:aqua;
margin: 0;
padding: 0;
width: 30%;
display: inline-block;
height: 800px;
}
#col2 {
background-color: antiquewhite;
margin: 0;
padding: 0;
width: 30%;
display: inline-block;
height: 800px;
}
#col3 {
background-color: aliceblue;
margin: 0;
padding: 0;
width: 30%;
display: inline-block;
height: 800px;
}
#footer {
margin: auto;
width: 90%;
background-color: aquamarine;
height: 200px;
}
https://css-tricks.com/fighting-the -space-between-inline-block-elements/ – sinisake
@sinisake謝謝你的鏈接,這非常有幫助! –