В моей таблице я пытаюсь изменить размер шрифта. Я попытался добавить размер шрифта в тег, добавив его в код CSS для класса Myposts, но ничего не превалировало. Как изменить размер шрифта?
<table width="100%" border="0" class = "Myposts"; align="center" cellpadding="3" cellspacing="1" bgcolor="#686868 " >
<tr>
<td width="6%" align="center" bgcolor="#505050 " ><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#505050 "><strong>Job Description</strong></td>
<td width="15%" align="center" bgcolor="#505050 "><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#505050 "><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#505050 "><strong>Date/Time</strong></td>
</tr>
Пожалуйста, не считайте это ответом, просто другим способом думать о проблеме. FIDDLE
Вы можете избавиться от "полужирной" строки, сделав первую строку <th>
вместо <td>
.
Добавьте стиль таблицы css в свой класс Myposts.
Вы заметили в заголовке, что это php, но я не вижу никаких php-тегов. Поэтому я предполагаю, что вы передаете php на страницу html, поэтому стилизация css все равно будет работать для вас.
HTML
<table class = "Myposts">
<tr>
<td>#</td>
<td>Job Description</td>
<td>Views</td>
<td>Replies</td>
<td>Date/Time</td>
</tr>
</table>
CSS
table {
width: 100%;
border: 0px solid black;
background-color: #686868;
border-spacing: 1px;
}
table td {
background-color: #505050;
color: white;
text-align: center;
font-weight: bold;
padding: 3px;
font-size: 20px;
}
table tr td:nth-child(1) {
width: 6%;
}
table tr td:nth-child(2) {
width: 53%;
}
table tr td:nth-child(3) {
width: 15%;
}
table tr td:nth-child(4) {
width: 13%;
}
table tr td:nth-child(5) {
width: 13%;
}
вы можете выбрать ячейки таблицы в CSS
table.Myposts tr td {
font-size: 18px;
}
.Myposts td {
font-size: 20px;
}
пример в jsfiddle: http://jsfiddle.net/Wk28Y/