使用css

时间:2018-04-23 13:09:20

标签: javascript html css angularjs

我是网络开发的新手。

我有以下代码



.notation {
  width: 170%;
  margin-left: -238px;
}

.mytable {
  margin: 0.5em auto;
  font-size: 90%;
  position: relative;
  width: 59%;
}

table.mytable>*>tr>td {
  border: 1px solid #a2a9b1;
  padding: 0.2em 0.4em;
}

table.mytable {
  background-color: #f8f9fa;
  color: #222;
  margin: 1em 0;
  border: 1px solid #a2a9b1;
  border-collapse: collapse;
}

<div class="col-md-12 table-responsive notation" ng-if="(documentType !== 'jobDescription')">
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody>
      <tr>
        <td style="width:2.5em; background-color:#fce8e8;text-align:center;"><b></b></td>
        <td>Full Name</td>
        <td style="width:2.5em; background-color:#e2d6f1;text-align:center;"></td>
        <td>Email</td>
        <td style="width:2.5em; background-color:aqua;text-align:center;"><b></b></td>
        <td>Telephone Number</td>
        <td style="width:2.5em; background-color:#ccfcdd;text-align:center;"><b></b></td>
        <td>Total Experience</td>
        <td style="width:2.5em; background-color:skyblue;text-align:center;"><b></b></td>
        <td>Skill Set</td>
      </tr>
    </tbody>
  </table>
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody>
      <tr>
        <td style="width:2.5em; background-color:#d1cff7;text-align:center;"><b></b></td>
        <td>Company Experience</td>
        <td style="width:2.5em; background-color:#e8dca7;text-align:center;"></td>
        <td>Education</td>
        <td style="width:2.5em; background-color:#10eabe;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="width:2.5em; background-color:#aee8dc;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="width:2.5em; background-color:#f2d7da;text-align:center;"><b></b></td>
        <td>Address</td>
      </tr>
    </tbody>
  </table>
</div>
&#13;
&#13;
&#13;

现在输出看起来像

enter image description here

但是在这里,发生了什么,这些东西没有对齐,我的意思是FullName占用的空间很小,但companyExperience占用了很多空间,所以我希望每个元素都对齐。

那么,我该怎么做?

更新 -

enter image description here

我得到了这种类型的输出。

2 个答案:

答案 0 :(得分:2)

这是你想要的那种输出吗?

.notation {
  width: 170%;
  margin-left: -238px;
}

.mytable {
  margin: 0.5em auto;
  font-size: 90%;
  position: relative;
  width: 59%;
}

table.mytable>*>tr>td {
  /*border: 1px solid #a2a9b1;*/
  padding: 0.2em 0.4em;
}

table.mytable {
  background-color: #f8f9fa;
  color: #222;
  margin: 1em 0;
  /*border: 1px solid #a2a9b1;*/
  border-collapse: collapse;
}
<div class="col-md-12 table-responsive notation" ng-if="(documentType !== 'jobDescription')">
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody>
      <tr>
        <td style="width:2.5em; background-color:#fce8e8;text-align:center;"><b></b></td>
        <td>Full Name</td>
        <td style="width:2.5em; background-color:#e2d6f1;text-align:center;"></td>
        <td>Email</td>
        <td style="width:2.5em; background-color:aqua;text-align:center;"><b></b></td>
        <td>Telephone Number</td>
        <td style="width:2.5em; background-color:#ccfcdd;text-align:center;"><b></b></td>
        <td>Total Experience</td>
        <td style="width:2.5em; background-color:skyblue;text-align:center;"><b></b></td>
        <td>Skill Set</td>
      </tr>
    <!--/tbody>
  </table>
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody-->
      <tr>
        <td style="width:2.5em; background-color:#d1cff7;text-align:center;"><b></b></td>
        <td>Company Experience</td>
        <td style="width:2.5em; background-color:#e8dca7;text-align:center;"></td>
        <td>Education</td>
        <td style="width:2.5em; background-color:#10eabe;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="width:2.5em; background-color:#aee8dc;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="width:2.5em; background-color:#f2d7da;text-align:center;"><b></b></td>
        <td>Address</td>
      </tr>
    </tbody>
  </table>
</div>

我只是将一些代码更改为注释。 (上面检查)
您不需要使用两个table,只需要使用两个tr

答案 1 :(得分:0)

&#13;
&#13;
.notation {
  width: 170%;
  margin-left: -238px;
}

.mytable {
  margin: 0.5em auto;
  font-size: 90%;
  position: relative;
  width: 59%;
}

table.mytable>*>tr>td {
  border: 1px solid #a2a9b1;
  padding: 0.2em 0.4em;
}

table.mytable {
  background-color: #f8f9fa;
  color: #222;
  margin: 1em 0;
  border: 1px solid #a2a9b1;
  border-collapse: collapse;
}

table.mytable td{
  width: 40px;
  max-width: 40px;
  font-size: 10px;
}
&#13;
<div class="col-md-12 table-responsive notation" ng-if="(documentType !== 'jobDescription')">
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody>
      <tr>
        <td style="background-color:#fce8e8;text-align:center;"><b></b></td>
        <td>Full Name</td>
        <td style="background-color:#e2d6f1;text-align:center;"></td>
        <td>Email</td>
        <td style="background-color:aqua;text-align:center;"><b></b></td>
        <td>Telephone Number</td>
        <td style="background-color:#ccfcdd;text-align:center;"><b></b></td>
        <td>Total Experience</td>
        <td style="background-color:skyblue;text-align:center;"><b></b></td>
        <td>Skill Set</td>
      </tr>
    </tbody>
  </table>
  <table class="mytable" style="margin:0.5em auto; font-size:90%;position:relative;width:60%;margin-bottom:13px;">
    <tbody>
      <tr>
        <td style="background-color:#d1cff7;text-align:center;"><b></b></td>
        <td>Company Experience</td>
        <td style="background-color:#e8dca7;text-align:center;"></td>
        <td>Education</td>
        <td style="background-color:#10eabe;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="background-color:#aee8dc;text-align:center;"><b></b></td>
        <td>Project</td>
        <td style="background-color:#f2d7da;text-align:center;"><b></b></td>
        <td>Address</td>
      </tr>
    </tbody>
  </table>
</div>
&#13;
&#13;
&#13;

如果你想将它们作为两个单独的表格