2017-02-01 9 views
1

私が作成しているテーブルでは、thtdを私が与えている高さにすることはできません。私のコードで見ることができるように、2つのフィールドとthがテーブル全体の高さを満たすように見えます。THとTDの高さが設定されていない

tdth80px60pxに設定するにはどうすればいいですか?

#staff-table { 
 
    width: 100%; 
 
    height: 600px; 
 
    border: 1px solid #CDCDCD; 
 
} 
 
th, td { 
 
    color: 303030; 
 
    padding: 10px; 
 
} 
 
th { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 1.2em; 
 
    font-weight: 600; 
 
    height: 80px; 
 
    background: #F7F7F7; 
 
} 
 
th:hover { 
 
    background: #F7F7F7; 
 
} 
 
tr { 
 
    border-bottom: 1px solid #EBEBEB; 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
tr:hover { 
 
    background: #09afdf;/*rgba(9, 175, 223, .4);*/ 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
td { 
 
    font-size: 1em; 
 
    font-family: 'Lato', sans-serif; 
 
    height: 60px; 
 
}
<table id="staff-table"> 
 
        <tr> 
 
         <th>First Name</th> 
 
         <th>Last Name</th> 
 
         <th>Print Name</th> 
 
         <th>Type</th> 
 
         <th>Balance</th> 
 
        </tr> 
 
        <tr> 
 
         <td>Georg</td> 
 
         <td>Reese</td> 
 
         <td>George Reese</td> 
 
         <td>Primary</td> 
 
         <td>32</td> 
 
        </tr> 
 
        <tr> 
 
         <td>Bob</td> 
 
         <td>Synder</td> 
 
         <td>Bob Snyder</td> 
 
         <td>Sales</td> 
 
         <td>10</td> 
 
        </tr> 
 
       </table>

答えて

3

はい、あなたが持っていることを意図している場合#staff-tableルール

#staff-table { 
 
    width: 100%; 
 
    min-height: 100px;  /* added based on comment, to keep a minimum height */ 
 
    border: 1px solid #CDCDCD; 
 
} 
 
th, td { 
 
    color: #303030; 
 
    padding: 10px; 
 
} 
 
th { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 1.2em; 
 
    font-weight: 600; 
 
    height: 80px; 
 
    background: #F7F7F7; 
 
} 
 
th:hover { 
 
    background: #F7F7F7; 
 
} 
 
tr { 
 
    border-bottom: 1px solid #EBEBEB; 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
tr:hover { 
 
    background: #09afdf;/*rgba(9, 175, 223, .4);*/ 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
td { 
 
    font-size: 1em; 
 
    font-family: 'Lato', sans-serif; 
 
    height: 60px; 
 
}
<table id="staff-table"> 
 
        <tr> 
 
         <th>First Name</th> 
 
         <th>Last Name</th> 
 
         <th>Print Name</th> 
 
         <th>Type</th> 
 
         <th>Balance</th> 
 
        </tr> 
 
        <tr> 
 
         <td>Georg</td> 
 
         <td>Reese</td> 
 
         <td>George Reese</td> 
 
         <td>Primary</td> 
 
         <td>32</td> 
 
        </tr> 
 
        <tr> 
 
         <td>Bob</td> 
 
         <td>Synder</td> 
 
         <td>Bob Snyder</td> 
 
         <td>Sales</td> 
 
         <td>10</td> 
 
        </tr> 
 
       </table>

+0

は、テーブル自体に高さを定義するためにとにかくあり、そのデータはそれにない場合、テーブルはまだ示して? – Paul

+0

@Paulはい...テーブルの「min-height」で答えが更新されました – LGSon

+0

助けてくれてありがとう! – Paul

1

height: 600pxを除去することによって、その一番上の行は、あなたが必要とする、その後600pxこと他のものからthに固有のIDまたはクラス。 #staff-tableは最初にすべてに適用されているので、それはそれになりますheight

#staff-table { 
 
    width: 100%; 
 
    border: 1px solid #CDCDCD; 
 
} 
 
th, td { 
 
    color: 303030; 
 
    padding: 10px; 
 
} 
 
th { 
 
    font-family: 'Source Sans Pro', sans-serif; 
 
    font-size: 1.2em; 
 
    font-weight: 600; 
 
    height: 80px; 
 
    background: #F7F7F7; 
 
} 
 
th:hover { 
 
    background: #F7F7F7; 
 
} 
 
tr { 
 
    border-bottom: 1px solid #EBEBEB; 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
tr:hover { 
 
    background: #09afdf;/*rgba(9, 175, 223, .4);*/ 
 
    transition:.5s; -webkit-transition:.5s; 
 
} 
 
td { 
 
    font-size: 1em; 
 
    font-family: 'Lato', sans-serif; 
 
    height: 60px; 
 
}
<table id="staff-table"> 
 
        <tr> 
 
         <th>First Name</th> 
 
         <th>Last Name</th> 
 
         <th>Print Name</th> 
 
         <th>Type</th> 
 
         <th>Balance</th> 
 
        </tr> 
 
        <tr> 
 
         <td>Georg</td> 
 
         <td>Reese</td> 
 
         <td>George Reese</td> 
 
         <td>Primary</td> 
 
         <td>32</td> 
 
        </tr> 
 
        <tr> 
 
         <td>Bob</td> 
 
         <td>Synder</td> 
 
         <td>Bob Snyder</td> 
 
         <td>Sales</td> 
 
         <td>10</td> 
 
        </tr> 
 
       </table>

関連する問題