使用form表单中自带的fieldset与legend

在form表单中常常被忽视的两个标签fieldsetlegend

下面我是用了bootstrap的样式,把一些默认样式去除了

<div class="container">
    <div class="col-md-5">
        <form role="form" action="" method="post">
            <fieldset>
                <legend class="text-center text-primary">用户注册页面</legend>
                <div class="form-group">
                    <label>用户名:</label>
                    <input type="text" name="name" placeholder="请输入用户名" class="form-control"/>
                </div>
                <div class="form-group">
                    <label>密码:</label>
                    <input type="text" name="password" placeholder="请输入密码" class="form-control"/>
                </div>
                <div class="form-group">
                    <label>选择你的性别:</label>
                    <div>
                        <label class="checkbox-inline" style="padding-left: 0;">
                            <input type="radio" name="sex" value="0">&nbsp;&nbsp;男
                        </label>
                        <label class="checkbox-inline" style="padding-left: 0;">
                            <input type="radio" name="sex" value="1">&nbsp;&nbsp;女
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="">选择你的兴趣爱好:</label>
                    <div>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="hobby" value="学习"/>&nbsp;&nbsp;学习
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="hobby" value="美女"/>&nbsp;&nbsp;美女
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="hobby" value="游戏"/>&nbsp;&nbsp;游戏
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="hobby" value="电话"/>&nbsp;&nbsp;电视
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label>请选择省份:</label>
                    <select class="form-control" name="province">
                        <option value="0">广东省</option>
                        <option value="1">湖南省</option>
                        <option value="2">广西省</option>
                        <option value="3">福建省</option>
                    </select>
                </div>
                <div class="form-group">
                    <input type="submit" value="注册" class="btn btn-primary"/>
                </div>
            </fieldset>
        </form>
    </div>
</div>

下面看个没样式的form表单

运行效果如图:
表单运行结果

<div style="width:400px;height: auto;">
    <form action="" method="post">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
        <fieldset>
            <legend>用户注册表</legend>
            <table>
                <tr>
                    <td><label>用户名:</label></td>
                    <td><input type="text" name="username"></td>
                </tr>
                <tr>
                    <td><label>密码:</label></td>
                    <td><input type="password" name="password"></td>
                </tr>
                <tr>
                    <td><label>年龄:</label></td>
                    <td><input type="text" name="age"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" value="提交"/></td>
                </tr>
            </table>
        </fieldset>
    </form>
</div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水痕01

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值