Angular 5无法在html表上调整单元格高度

前端之家收集整理的这篇文章主要介绍了Angular 5无法在html表上调整单元格高度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的角度应用程序中,我有一个代表一个html表的组件.我遇到的问题是我无法降低细胞高度.好像我的css对显示器没有影响.

这里标题&我的component.ts中的catNames var:

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

这是我的组件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>

这是我的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;
}

如何显示,我想删除顶部和顶部的额外空间细胞的下边界:

html table display

我的CSS值有错吗?

解决方法

删除< P>标签 .因为它会给自己填充.否则在减号中给出填充.但这不是正确的方法.所以最好的方法删除< p>并且仅使用插值,它将被视为文本.或者您可以直接将css提供给< p>而不是td.

猜你在找的Angularjs相关文章