html - 彼此相邻的 float div

标签 html css

我正在尝试在我网站的列表标签内创建以下位置 enter image description here

这是我的代码:

<li>
    <a href="http://www.example.com/test/">
        <div class="bt-thumb" style="float:left;background: url(http://www.example.com/wp-content/uploads/2016/09/bg1.jpg) no-repeat center center / cover, #333"></div>
    </a>
    <h6 class="">
        <a href="http://www.example.com/test/">Test Post</a>
    </h6>
    <div class="">
        <span>Sep 29, 2016</span>
        <span>By Admin</span>
    </div>
</li>

但我只是让每个元素堆叠在彼此之上 任何帮助将不胜感激。

谢谢

最佳答案

首先是 html 标记,将元素相互包裹的方式很糟糕……把它放在一边……这是您所要求的最低工作版本。

.bt-thumb {
  display: inline-block;
  float:left;
  width: 200px;
  height: 200px;
  margin: 10px;
}

http://codepen.io/anon/pen/kkZkJq

关于html - 彼此相邻的 float div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39906117/

相关文章:

html - 我应该使用 <table> 还是 <ul>?

css - 如何在 Tailwind CSS 中使用 CSS 变量

javascript - 自动滚动到消息底部

css - 过渡不是第一次发生

javascript - 更改 w3 示例表过滤器以搜索多列

html - MVC4 项目图像不显示

javascript - node.js WebSocket 服务器

javascript - jquery验证器错误位置

javascript - 表单提交后,主页卡住,而 pdf 未加载到新页面上

jquery - 根据父 DIV 宽度动态浮点对齐 DIV