如何将样式类应用于td类? [英] How to apply style classes to td classes?
本文介绍了如何将样式类应用于td类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要找出的是正确的语法,以便对下表中的每个单独的td应用某种样式:
what I am trying to find out is the proper syntax to apply some style to each individual td in my table below:
<section id="shows">
<!-- HTML5 section tag for the shows 'section' -->
<h2 class="gig">Shows</h2>
<ul class="gig">
<!-- Start the table -->
<table>
<tr>
<!-- Setup the header row -->
<th>When</th>
<th>Where</th>
<th>Start</th>
<th>Finish</th>
</tr>
<?php
// some PHP to fetch all the gig entries from the shows table
$shows_query = "SELECT * FROM shows ORDER BY date ASC";
$shows = mysql_query($shows_query);
// a loop to place all the values in the appropriate table cells
while ($show = mysql_fetch_array($shows)){
//begin the loop...
?>
<!-- Start the row -->
<tr>
<!-- Format the date value from the database and print it: -->
<td class="when"><?php
$date = date("l, F j, Y", strtotime($show['date']));
echo "$date";
?></td>
<td class="venue"><?php
echo $show['venue'];
?></td>
<!-- Format the the start and end times and print them: -->
<td class="start"><?php
$time = date("G:i", strtotime($show['time']));
echo "$time";
?></td>
<td class="finish"><?php
$until = date("G:i", strtotime($show['until']));
echo "$until";
?></td>
<!-- Finish this row -->
</tr>
<!-- Some space before the next row -->
<div class="clear"></div>
<?php
// close the loop:
}
?>
<!-- Finish the table -->
</table>
</ul>
</section>
我目前的风格是:
#shows table.gig { font-size: 25px; }
#shows td.finish { margin-left: 50px;}
我确实有一个表本身的类,但是不确定是否有必要.
I did have a class for the table itself but not sure if it's necessary.
字体大小有效,但我不知道如何将样式应用于td,th,tr元素等.我尝试了几件事,但似乎无法使其正常工作!
The font-size works but what I can't figure out is how to apply the style to the td, th, tr elements etc. I have tried several things but can't seem to get it to work!
非常感谢您的帮助.
谢谢.
推荐答案
为表指定一个类名,然后使用以下内容定位td:
Give the table a class name and then you target the td's with the following:
table.classname td {
font-size: 90%;
}
这篇关于如何将样式类应用于td类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文