博客列表 >Bootstrap全局样式中的表格与表单 —2018年9月25日23时45分

Bootstrap全局样式中的表格与表单 —2018年9月25日23时45分

感恩的心的博客
感恩的心的博客原创
2018年10月03日 08:54:28811浏览

用水平表单制作一个完整用户登陆页面

实例

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.css">
        <title>水平表单</title>
    </head>
    <body>
        <div class='container'>
            <div class="row">
                <div class='col-md-6 col-md-offset-3'>
                    <h3 class="text-center">用户登录</h3>
                    <form action="" class="form-horizontal">
                        <div class="form-group">
                            <label for="email" class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-10">
                                <input type="email" id="Email" class="form-control" placeholder="Email">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" id="password" class="form-control" placeholder="assword">
                            </div>
                        </div>


                        <div class="form-group">
                            <label for="file" class="col-sm-2 control-label">文件上传:</label>
                            <input type="file" >
                            <p class="help-block">文件必须是jpg/png/gif图片格式</p>
                        </div>

                        <div class="form-group">
                            <label for="level" class="col-sm-2 control-label">学历:</label>
                            <div class="col-sm-10">
                                <select name="level" id="level" class="form-control">
                                    <option value="0">高中</option>
                                    <option value="1">本科</option>
                                    <option value="2">博士</option>
                                </select>
                            </div>

                        </div>

                        <div class="form-group">
                            <label for="comment" class="col-sm-2 control-label">留言:</label>
                            <div class="col-sm-10">
                                <textarea name="comment" id="comment" class="form-control col-sm-10" rows="3"></textarea>
                            </div>
                        </div>

                        <!--复选框与按钮组非常特殊,不能使用控件组进行控制-->
<!--                        <label class="col-sm-2">选择课程:</label>
                        <div class="checkbox col-sm-offset-2">
                            <label class="">
                                <input type="checkbox" name="course[]" value="front"> 前端
                            </label>
                        </div>

                        <div class="checkbox col-sm-offset-4">
                            <label>
                                <input type="checkbox" name="course[]" value="server" checked> 后端
                            </label>
                        </div>

                        <div class="checkbox disabled col-sm-offset-6">
                            <label>
                                <input type="checkbox" name="course[]" value="full-stack" disabled> 全栈
                            </label>
                        </div>-->

                        <!--将上面的复选框改成水平排列-->
                        <label>选择课程:</label>
                        <div class="checkbox-inline">
                            <label>
                                <input type="checkbox" name="course[]" value="front"> 前端
                            </label>
                        </div>

                        <div class="checkbox-inline">
                            <label>
                                <input type="checkbox" name="course[]" value="server" checked> 后端
                            </label>
                        </div>

                        <div class="checkbox-inline disabled">
                            <label>
                                <input type="checkbox" name="course[]" value="full-stack" disabled> 全栈
                            </label>
                        </div>
                        
                        <br>

<!--                        <label>选择性别:</label>
                        <div class="radio">
                            <label>
                                <input type="radio" name="gender"  checked>男
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="gender">女
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="gender"  disabled>待定
                            </label>
                        </div>-->

                        <label>选择性别:</label>
                        <div class="radio-inline">
                            <label>
                                <input type="radio" name="gender"  checked>男
                            </label>
                        </div>
                        <div class="radio-inline">
                            <label>
                                <input type="radio" name="gender">女
                            </label>
                        </div>
                        <div class="radio-inline">
                            <label>
                                <input type="radio" name="gender"  disabled>待定
                            </label>
                        </div>

                        <!--如果想省略掉checkbox和radio中的文本标签内容,怎么办?-->
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" name="name" aria-label="用户名">
                            </label>
                        </div>
                        <div class="radio col-sm-10 col-sm-offset-2">
                            <label>
                                <input type="radio" name="name" aria-label="是否同意?">
                            </label>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-10 col-sm-offset-2">
                                <button class="btn btn-primary btn-block">提交</button>
                            </div>
                        </div>
                    </form>

                </div>

            </div>


        </div>
    </body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议