Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 can not resize cell height on a html table

Tags:

html

css

angular

On my angular application I have a component that represents simply a html table. The issue I have is that I am unable to reduce cells height. Seems like my css has no impact on the display.

Here headers & catNames var in my component.ts :

catNames : string[] = ["Toto", "Tata", "Titi", "Mama", "Momo"];
headers: string[] = ["Head1", "Head2", "Head3", "Head4", "Head5"];

Here's my component HTML :

<table>
  <tr>
    <th *ngFor="let header of headers">
        {{header}}
    </th>
  </tr>
  <tr>
    <td *ngFor="let cat of catNames">
        <p>{{cat}}</p>
    </td>
  </tr>
</table>

Here's my CSS :

table {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    border-collapse: collapse;
    text-align: center;
    width: 100%;
    font-size: 12pt;
}

th {
    border: 1px solid #dddddd;
    text-align: center;
    padding: 0px;
    color: white;
    background-color: dodgerblue;
}

td {
    display:table-cell;
    border: 1px solid #dddddd;
    text-align:  center;
    margin: 0;
    padding: 0;
    border-spacing: 0;
}

How it is displayed, I want to remove the extra space on top & bottom border of the cell :

html table display

Any mistakes in my CSS values?

like image 949
Logan Wlv Avatar asked Mar 05 '23 10:03

Logan Wlv


1 Answers

Remove <P> tag . Because it will give padding itself. Otherwise give padding in minus. But that's not proper way. So best way is to remove <p> and use only interpolation value it will be taken as text. Or you can give css directly to <p> instead of td.

like image 98
Aarsh Avatar answered Mar 16 '23 19:03

Aarsh