星空网 > 软件开发 > 网页设计

第七篇.表单

Bootstrap提供了三种表单布局:垂直表单,内联表单和水平表单

创建垂直或基本表单:

  • ·向父 <form> 元素添加 role="form"
  • ·把标签和控件放在一个带有 class .form-group 的 <div> 中。这是获取最佳间距所必需的。
  • ·向所有的文本元素 <input>、<textarea> 和 <select> 添加 class .form-control

 

<form role="form">

            <div >

                <label for="name">名称</label>

                <input type="text" id="name"

                       placeholder="请输入名称">

            </div>

            <div >

                <label for="inputfile">文件输入</label>

                <input type="file" id="inputfile">

                <p >这里是块级帮助文本的实例。</p>

            </div>

            <div >

                <label>

                    <input type="checkbox"> 请打勾

                </label>

            </div>

            <button type="submit" >提交</button>

        </form>

 第七篇.表单

 

 

 

内联表单:

内联表单中所有元素都向左对齐,标签并排,要创建内联表单,需要在form标签中加入class

.form-inline

<form role="form">

            <div >

                <label for="name">名称</label>

                <input type="text" id="name"

                       placeholder="请输入名称">

            </div>

            <div >

                <label for="inputfile">文件输入</label>

                <input type="file" id="inputfile">

            </div>

            <div >

                <label>

                    <input type="checkbox"> 请打勾

                </label>

            </div>

            <button type="submit" >提交</button>

        </form>

显示效果如下:

 第七篇.表单

 

注意:默认情况下,Bootstrap 中的 input、select 和 textarea 有 100% 宽度。在使用内联表单时,需要在表单控件上设置一个宽度。

水平表单:和其它两种表单有所不同,要创建水平表单需要遵循以下步骤.

  • 向父 <form> 元素添加 class .form-horizontal
  • 把标签和控件放在一个带有 class .form-group 的 <div> 中。
  • 向标签添加 class .control-label

例如:

<form role="form">

            <div >

                <label for="firstname" >名字</label>

                <div >

                    <input type="text" id="firstname"

                           placeholder="请输入名字">

                </div>

            </div>

            <div >

                <label for="lastname" >姓</label>

                <div >

                    <input type="text" id="lastname"

                           placeholder="请输入姓">

                </div>

            </div>

            <div >

                <div >

                    <div >

                        <label>

                            <input type="checkbox"> 请记住我

                        </label>

                    </div>

                </div>

            </div>

            <div >

                <div >

                    <button type="submit" >登录</button>

                </div>

            </div>

        </form>

 第七篇.表单

 

 




原标题:第七篇.表单

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

美国零售服务提供商b8ta获5000万美元C轮融资:https://www.ikjzd.com/articles/109992
警惕!2019年底外贸骗局大曝光!:https://www.ikjzd.com/articles/109993
亚马逊如何有效分析竞争对手Google广告数据?:https://www.ikjzd.com/articles/109994
最新揭秘:曝光你不知道的亚马逊A9算法变化!:https://www.ikjzd.com/articles/109995
Shopee跨境电商新手运营问题分析:什么是SIP一店通?:https://www.ikjzd.com/articles/109996
亚马逊卖家注意!这些产品一碰就死:https://www.ikjzd.com/articles/109997
独家对话爆剧操盘手刘羽砚:短剧凭什么让2亿人花钱观看? :https://www.kjdsnews.com/a/1836539.html
大牌退烧 白牌雄起? :https://www.kjdsnews.com/a/1836540.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流