html – 如何将样式类应用于td类?

前端之家收集整理的这篇文章主要介绍了html – 如何将样式类应用于td类?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要找出的是适用的语法,在我的表格中的每个单独的td应用一些风格:
<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;}

我确实有一个表的本身,但不知道是否有必要.

字体大小的工作,但我无法想像的是如何将样式应用到td,th,tr元素等.我已经尝试了几件事,但似乎无法让它工作!

任何帮助非常感谢.

谢谢.

解决方法

给表一个类名,然后你使用以下命令定位td:
table.classname td {
    font-size: 90%;
}
原文链接:https://www.f2er.com/html/230736.html

猜你在找的HTML相关文章