html - 将 DIV 容器放入 DIV 容器时出现意外空间

标签 html css position containers absolute

正如您从标题中所读到的,我在将 1 个 DIV 容器和一个图像放入 DIV 容器时遇到了问题。

* {
  margin: 0;
  padding: 0;
  border: 0;
}

.placeholder {
  height: 200px width: 100px;
  background-color: blue;
}

#thumb_container {
  width: 500px;
  height: 500px;
  margin: auto;
  background-color: #333;
}

#thumb_container > ul {
  list-style-type: none;
}

#thumb_container > ul > li {
  display: inline-block;
  background-color: #777;
}

.thumb_box {
  width: 100%;
  background-color: blue;
  position: relative;
}

.thumb_info {
  width: 100%;
  background-color: yellow;
  opacity: .5;
  position: absolute;
  bottom: 0;
}
<div id="thumb_container">
  <ul>
    <li>
      <div class="thumb_box">
        <img src="http://i.imgur.com/MussUUm.jpg">
        <div class="thumb_info">
          Test
        </div>
      </div>
    </li>
    <ul>
</div>

jsfiddle

除了蓝色的 DIV .thumb_box 和另一个 DIV .thumb_info 之外,它几乎可以正常工作 在一起有点太大,我不知道为什么。我不明白它为什么要花钱。

最佳答案

我猜:

img {
    display: block;
}

关于html - 将 DIV 容器放入 DIV 容器时出现意外空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33278704/

相关文章:

css - 使用 CSS 移动元素

css - Bootstrap CSS 底层类不工作

button - 将 JavaFX 按钮定位在特定位置

javascript - 使用键盘向上/向下箭头导航表 <tr>

html - Bootstrap-rails,如何改变车身尺寸?

html - Themeroller 图标没有在我期望的位置排列

javascript - 通过附加和前置空格在 javascript 函数中换行和居中对齐

javascript - Vue.js - 在悬停时添加删除按钮并在按下按钮时将其删除

html - 提交按钮周围带有渐变的奇怪边框。我该如何删除?

c# - 找到 Canvas 的左上角位置