创建一个表格,使用类选择器来美化表格样式?

本文介绍了一种使用CSS类选择器美化HTML表格的方法,通过定义特定的样式类,可以实现对表格背景、边框、字体等元素的个性化定制。示例中包括了输入字段、单选按钮、复选框、下拉菜单等多种表单元素,展示了如何将这些元素整合到一个美观且功能完整的注册表单中。

创建一个表格,使用类选择器来美化表格样式:

代码如下:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>创建一个表格,使用类选择器美化</title>
    </head>
    <style>
        /*border-style 设置边框的线是实线
         border-color 设置边框颜色*/
        a:link{text-decoration: none;font-size: 20px;}
        .table{background: cyan; border-style: solid;border=1;border-color:pink;font-family: "楷体";font-size: medium;}
        .fieldset{width:500px; height: 80; text-align: center; font-size:25px;font-family: "微软雅黑";}
    </style>
    <body>
        <a href="http://www.baidu.com" target="_blank">百度一下,你就知道</a>
        <fieldset class="fieldset"> <legend>新用户注册:</legend>
            <table   align="center" class="table" border= "1">
                <thead align="center">填写个人信息</thead>
                <tbody align="center">
                <tr>
                    <th>姓名</th>
                    <th><input type="text" name="user"/></th>
                </tr>
                <tr>
                    <th>密码</th>
                    <th><input type="password" name="ps"/></th>
                </tr>
                <tr>
                    <th>性别</th>
                    <th><input type="radio" name="sex" value="男" checked="checked"/>男
                    <input type="radio" name="sex"value="女"/>女
                    </th>
                </tr>
                <tr>
                    <th>头像</th>
                    <th><input type="file" value="上传头像"/>
                    </th>
                </tr>
                <tr>
                    <th>爱好</th>
                    <th><input type="checkbox" name="hobby" value="篮球" />篮球
                    <input type="checkbox" name="hobby" value="跑步"/>跑步
                    <input type="checkbox" name="hobby" value="游泳"/>游泳
                    <input type="checkbox" name="hobby" value="煲剧"/>煲剧
                    <input type="checkbox" name="hobby" value="其他" checked="checked"/>其他
                    </th>
                </tr>
                    <tr>
                    <th>城市</th>
                    <th><select>
                        <option value="1" selected="selected">请选择城市?</option>
                        <option value="2">北京</option>
                        <option value="2">上海</option>
                        <option value="2">南京</option>
                        <option value="2">天津</option>
                        <option value="2">四川</option>
                    </select>
                    </th>
                </tr>
                    <tr>
                    <th>自我介绍</th>
                    <th><textarea>请填写自我介绍,不超过20个字!
                    </textarea>
                    </th>
                </tr>
                </tr>
                    <tr>
                    <th colspan="2">
                        <input type="submit" value="提交" />
                        <input type="reset" value="重置" />
                    </th>
                    
                    </th>
                </tr></tbody>
            </table>
        </fieldset>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值