HTML和CSS 表单、表格练习

HTML和CSS 表格练习

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML表格练习</title>

    <style>
        .container {
            width: 80%;
            margin: 0 auto;
            /* 水平居中 上下不变,左右自动调整 */
        }

        .table {
            border: 2px solid black;
            /* 边框 */
            border-collapse: collapse;
            width: 100%;
            margin-top: 50px;
            /* 距离上一个元素的距离: 50px */
        }

        .table td,.table th {
            border: 2px solid #ddd;
            padding: 5px;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="container">
        <table class="table">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>年龄</th>
                    <th>性别</th>
                </tr>
            </thead>

            <tbody>
                <tr>
                    <td>张三</td>
                    <td>18</td>
                    <td>男</td>
                </tr>
                <tr>
                    <td>李四</td>
                    <td>24</td>
                    <td>男</td>
                </tr>
                <tr>
                    <td>王五</td>
                    <td>25</td>
                    <td>男</td>
                </tr>
            </tbody>

        </table>
    </div>

</body>

</html>

HTML和CSS 表单练习

html 复制代码
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单练习</title>
    <style>
        .form {
            display: flex;
            /* 启用弹性布局 */
            justify-content: space-between;
            padding: 20px;
            background-color: #f9f9f9;
        }

        .form label {
            margin-right: 20px;
            padding: 5px 10px;
        }

        .form input,
        .form select {
            margin-right: 50px;
            padding: 5px 10px;
            /* border-color: 1px solid #ccc; */
            border-radius: 5px;
            width: 260px;
        }

        .container {
            width: 80%;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <div class="container">
        <form action="#" method="post" class="form">
            <div>
                <label for="gender">性别</label>
                <select name="gender" id="gender">
                    <option value="0">请选择学生性别</option>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select>
            </div>

            <div>
                <label for="gender">性别</label>
                <select name="gender" id="gender">
                    <option value="0">请选择学生性别</option>
                    <option value="1">男</option>
                    <option value="2">女</option>
                </select>
            </div>

            <div>
                <label for="job">职位</label>
                <select name="job" id="job">
                    <option value="0">请选择学生职位</option>
                    <option value="1">班长</option>
                    <option value="2">副班长</option>
                    <option value="3">课代表</option>
                    <option value="4">无</option>
                </select>
            </div>



        </form>

    </div>

</body>

</html>
相关推荐
Mr_Mao3 小时前
Naive Ultra:中后台 Naive UI 增强组件库
前端
前端小趴菜055 小时前
React-React.memo-props比较机制
前端·javascript·react.js
摸鱼仙人~6 小时前
styled-components:现代React样式解决方案
前端·react.js·前端框架
sasaraku.6 小时前
serviceWorker缓存资源
前端
RadiumAg7 小时前
记一道有趣的面试题
前端·javascript
yangzhi_emo8 小时前
ES6笔记2
开发语言·前端·javascript
yanlele8 小时前
我用爬虫抓取了 25 年 5 月掘金热门面试文章
前端·javascript·面试
中微子9 小时前
React状态管理最佳实践
前端
烛阴9 小时前
void 0 的奥秘:解锁 JavaScript 中 undefined 的正确打开方式
前端·javascript
中微子9 小时前
JavaScript 事件与 React 合成事件完全指南:从入门到精通
前端