ganesh kaspate
ganesh kaspate

Reputation: 2685

Aligning the elements In the same manner using css

I am new to web development.

I have the following code:

.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>

Now the output looks like

enter image description here

But here, What is happening, this things are not getting aligned, I mean FullName is taking small space but the companyExperience is taking much space so, I want to have every element aligned.

So, How can I do this ?

Updated-

enter image description here

I am getting this type of output.

Upvotes: 3

Views: 99

Answers (2)

Takit Isy
Takit Isy

Reputation: 10081

Is this the kind of output you want ?

.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>

I only changed some of your code as comments. (Check it above)
You didn't need to use two tables, only two trs.

Upvotes: 2

Kieran
Kieran

Reputation: 656

.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;
}
<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>

If you want them as two seperate tables

Upvotes: 0

Related Questions