html - Div 位置内联 block

标签 html css

我想要 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/

相关文章:

css - 为什么我的下拉菜单没有出现?

javascript - 无法让页脚保持向下状态(HTML/CSS 初学者)

html - 绝对定位 tr

javascript - 根据复选框更改 HTML 值

php - 我创建了一个 CSS 切换器,但我只需要更改 body 类为 ="red"的元素

php - 从 mysql/php 引用下拉列表中选择的选项

html - 在移动设备上垂直居中元素

php - 向 WordPress 中的所有 url 添加一些参数

javascript - 如何为这个 jQuery 代码定义 if 语句?

带有CSS箭头的Jquery UI Tab导航