gpt4 book ai didi

html - Div 位置内联 block

转载 作者:太空宇宙 更新时间:2023-11-04 03:22:41 25 4
gpt4 key购买 nike

我想要 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 添加到 .tablecssinline-block 默认将对象设置为 baseline:

.imgcss {
height:300px;
width:200px;
background-color:#CCC;
display:inline-block
}

.tablecss {
display:inline-block;
vertical-align:top; <----
}

FIDDLE

关于html - Div 位置内联 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27653325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com