我想创建一个仅用于实验目的的三列布局,但是当我尝试让这些列内联时,它们之间会出现一个间隙,这些间距将显示在我已链接的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谢谢你的链接,这非常有帮助! –