我想要 2 div 显示内联 block ,下面这段代码
.imgcss {
height:300px;
width:200px;
background-color:#CCC;
display:inline-block}
.tablecss {
display:inline-block;}
<div class="container">
<div class="imgcss">
</div>
<div class="tablecss">
<table width="auto" border="1">
<tr>
<td>USER1</td>
<td>2000</td>
</tr>
<tr>
<td>USER2</td>
<td>2005</td>
</tr>
<tr>
<td>USER3</td>
<td>2010</td>
</tr>
</table>
</div>
</div>
但它并没有像我想要的那样显示。你可以看到这张图
http://i.stack.imgur.com/IPayZ.jpg
我希望它像这样显示:
http://i.stack.imgur.com/FyKDl.jpg
怎么做?谢谢你
最佳答案
将 vertical-align: top
添加到 .tablecss
。 inline-block
默认将对象设置为 baseline
:
.imgcss {
height:300px;
width:200px;
background-color:#CCC;
display:inline-block
}
.tablecss {
display:inline-block;
vertical-align:top; <----
}
关于html - Div 位置内联 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27653325/