如何增加表中所有tds的字体大小

时间:2017-02-20 05:25:29

标签: html css

我有桌子,有些行在那里。我想在etire表中将td字体大小增加到24。如何在头部写入td的css样式,以便增加所有td数据的字体大小。

<table class="table table-striped">
  <thead>
    <tr class="success">
      <th class="success">a</th>
      <th>1</th>
      <th>2</th>
      <th>3</th>
      <th>4</th>
      <th>5</th>
    </tr>
  </thead>
  <tbody>
    <tr class="danger">
      <td id="hhh" class="success">filled</td>
      @foreach (var item in Model) {
      <td>@item.Filled.ToString("N2") cm</td>
      }
    </tr>
    <tr class="info">
      <td>Updated time</td>
      @foreach (var item in Model) {
      <td>@item.UpdatedTime</td>
      }
    </tr>
    <tr class="warning">
      <td>Area</td>
      @foreach (var item in Model) {
      <td>@item.Area</td>
      }
    </tr>
  </tbody>
</table>

5 个答案:

答案 0 :(得分:4)

你可以嵌套这样的东西:

table tbody tr td {
  font-size: 24px;
}

或者你可以保持简单而且只是这样做:

td {
  font-size: 24px;
}

这取决于CSS的上下文,您需要具体的具体情况。机会是第二种选择。

答案 1 :(得分:2)

选择table选择器并为所有style元素提供td,就像那样简单..

table td{
    font-size:24px;
}

答案 2 :(得分:1)

检查此代码

.table td {
  font-size: 30px;
}

Live

答案 3 :(得分:1)

你可以直接在你的html文件中执行此操作:

<style>
 table td {
   font-size: 24px;
 }
</style>

<table class="table table-striped">
  ...
</table>

或者你可以创建新的css文件 style.css

<link rel="stylesheet" type="text/css" href="style.css">

<table class="table table-striped">
  ...
</table>

并在style.css中:

table td {
  font-size: 24px;
}

答案 4 :(得分:0)

您也可以使用

<style>
.mytable td{
  font-size:24px;
}
</style>
<table class="mytable">
<tbody>
  <tr>
    <td>ABC</td>
    <td>DEF</td>
  </tr>
</tbody>
</table>
相关问题