html - 在 Div 中对齐内容

标签 html css

我有什么

我有这张 table 。

enter image description here

用这个HTML

<div class="list-item">
<p>
 <input type="checkbox">
 <span class="list-type"><img src="/images/types/{{this.type}}.png" title="{{this.type}}" /></span> 
 <span class="list-title">{{this.title}}</span> 
 <span class="list-owner">{{this.owner}}</span>
 <span class="list-date">16 Dec 2014</span>
</p>
 </div><br>

有了这个CSS

.list-item{
  display: inline-block;
  width: 100%;
  border: solid 1px #dddddd;
}

.list-type{
  margin-left: 10px;
  margin-right: 10px;
}

我想完成什么

但我想在 <div> 中创建类似表格的内容.

注意 我知道 <table>非常适合,但对于如何创建此内容,我需要用这个 <div> 模拟一个表,所以不幸的是,它不是这里的选项。

我需要复制这样的东西(检查图像)。

enter image description here

注意忽略星标

我已经尝试过的


设置margin-left每个 <span>但是“管理员”和“日期”的顺序不相等,如果我使用边距我会得到这个(检查图片)。

enter image description here

我用这个 CSS

.list-item{
  display: inline-block;
  width: 100%;
  border: solid 1px #dddddd;
}

.list-type{
 margin-left: 10px;
}

.list-title{
   margin-left: 10px;
}

.list-owner{
  margin-left: 100px;
}

.list-date{
  margin-left: 190px;
}

最佳答案

试试 CSS 表格:

.list-item {
  display: table;
}
.list-item > p {
  display: table-row;
}
.list-item > p > * {
  display: table-cell;
}

关于html - 在 Div 中对齐内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30444971/

相关文章:

javascript - .fadeIn() 和 .fadeOut() 功能坏了?

javascript - 使用 MagicSuggest 将变量发送到服务器

javascript - anythingslider navigationsize 不适用于首次加载 firefox 26

javascript - 如何清除和更改 Canvas 的背景颜色?

javascript - 圆形按钮内的换行符不起作用

css - 悬停按钮背景颜色保留在移动设备上

javascript - 3 行布局,100% 高度 : 1 auto, 1 自动滚动,1 固定

css - 拉出移动导航时如何禁用水平滚动?

javascript - 单击 Jquery JS 时按钮重新打开

HTML5 PostMessage 跨域问题