将td对齐到表

时间:2016-02-09 12:49:31

标签: html css

大家好先让我开始作为小提琴上的一个例子我用了一部分研究项目:

https://jsfiddle.net/onpfb83g/

css非常基本:

body {
  background-color: white;
  font-family: Arial;
}

.box h1 {
  color: navy;
  margin-left: 20px;
  text-align: center;
  display: block;
  font-size: 2em;
  -webkit-margin-before: 0.67em;
  -webkit-margin-after: 0.67em;
  -webkit-margin-start: 0px;
  -webkit-margin-end: 0px;
  font-weight: bold;
}

.box {
  width: 480px;
  height: 480px;
  position: relative;
}

.box table {
  display: table;
  border-collapse: separate;
  border-spacing: 2px;
  border-color: grey;
}

.box .images td {
  padding: 0px;
  border-left: none;
  border-right: none;
  background-color: white;
  text-align: center;
  font-size: 90%;
  font-style: italic;
  font-weight: bold;
}

.box .images img {
  width: 100px;
  height: 100px;
}

.box .attributes td {
  margin-top: 0;
  padding-top: 0;
  border-left: none;
  border-right: none;
  background-color: white;
}

.box .attributes td {
  border-bottom: 1px solid #ddd;
}

.box .even td {
  background-color: #eee;
  border-bottom: none;
}

.box .odd td {
  background-color: white;
  border-bottom: none;
}

.box .actions {
  margin: 40px
}

.box .expander {
  width: 30px;
  height: 30px;
  position: absolute;
  bottom: 0px;
  right: 0px;
}

.header {
  background-color: #ccc;
  border-bottom: 3px solid #999;
  border-top: 3px solid #999;
  font-weight: bold;
  font-style: italic;
  position: absolute;
}

#summary_row {
  height: 100px;
  font-size: 110%;
}

#summary_cpn {
  color: #F00;
  font-weight: bold;
}

.box .thumbnail:hover {
  position: relative;
  top: 25px;
  left: 35px;
  width: 150%;
  height: auto;
  display: block;
  z-index: 999;
  box-shadow: 10px 10px 5px #888888;
}

你可以看到那个带有文字的表格"图形" tn不是同一个"等级"作为第一行"测试desc"我的问题是,我做错了怎样才能将第二列对齐?我尝试使用padding-top:0,margin-top:0但是没有给出任何结果

2 个答案:

答案 0 :(得分:0)

<p>Graphic</p>移至新的tr

    <tr>
        <td colspan="3">
          <p>Graphic</p>
        </td>
      </tr>
      <tr>
        <td class="images">
          <img class="thumbnail" src="https://disastersafety.org/wp-content/uploads/SXC-Test-Graphic-1335048_63274538.jpg">
        </td>
</tr>

Updated Fiddle

答案 1 :(得分:0)

尝试添加以下规则:

.column-header {  
  vertical-align: top;
}

.images p {
  margin: 0;
}

https://jsfiddle.net/onpfb83g/2/