【问题标题】:How to make bootstrap 3.1.0 form collapse like bootstrap navbar如何让 bootstrap 3.1.0 表单像 bootstrap navbar 一样崩溃
【发布时间】:2014-08-25 20:40:02
【问题描述】:

我需要使 bootstrap v3.1.0 表单可折叠并且与 bootstrap 导航栏 100% 相似。当引导导航栏折叠时它会折叠。请帮我。这是我的html代码:

 <div class="form-container">
        <div class="contact-form">

            <div class="form-text">

                <h3>Free Advice And Consultation</h3>

            </div>



            <form class="form-inline" role="form">

                    <div class="form-group middle-form">
                        <label for="exampleInputEmail2">Name</label>
                        <input type="name" class="form-control" id="exampleInputName" placeholder="Enter name">
                    </div>

                    <div class="form-group middle-form">
                        <label for="exampleInputPhone">Phone</label>
                        <input type="phone" class="form-control" id="exampleInputPhone" placeholder="Phone">
                    </div>  

                    <div class="form-group middle-form">
                        <label for="exampleInputEmail2">Email address</label>
                        <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">
                    </div>

                    <div class="form-group middle-form">
                    <label for="exampleInputEmail2">Treatment</label>
                    <select class="form-control">
                        <option>Relaxation Massage</option>
                        <option>Remedial Massage</option>
                        <option>Sports Massage</option>
                        <option>Trigger Point Massage</option>
                        <option>Float Bath</option>
                        <option>Infrared Sauna</option>
                    </select>
                    </div>

                      <button type="submit" class="btn btn-default middle-form">Send</button>
            </form>

        </div>
    </div>

CSS:

 .form-container{
    max-width: 1230px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;

}

.contact-form{
    width:100%;
    height:auto;
    max-width:1680px;
    background-color: #ac9762;
}
.form-text{
    float:left; 
    width:230px;
}

.border-top{
    padding-top: 30px;
    padding-left: 30px;
    height: 3px solid #fefdfc;
    width:10px;
    background-color:#fefdfc;
    }
.form-text h3{
    padding-top: 30px;
    padding-left: 30px;
    font-size:20px;
    font-weight:bold;
    color:#fefdfc;

}

label{
    display: block;
    padding-top: 30px;

}
.form-control{
    margin-bottom: 30px;
    border-radius: 0px;
    margin-right: 30px;

}

.contact-form .btn{
    border-radius: 0px;
    margin-top: 24px;
}

.contact-form  .btn-default{
    background-color: #090805;
    border-color: #090805;
    padding-top: 5px;
    color: #fefdfc;
}

.contact-form h3:before {

    width: 4.5%;
    background: none repeat scroll 0 0 #fefdfc;
    border-top: 1px solid #fefdfc;
    content: "";
    height: 5px;
    position: absolute;
    margin-top: -10px;
}

【问题讨论】:

标签: javascript jquery html css twitter-bootstrap


【解决方案1】:

试试这个:

DEMO

CSS:

.form-container{
    max-width: 1230px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;

}

.contact-form{
    width:100%;
    height:auto;
    max-width:1680px;
    background-color: #ac9762;
}
.form-text{
    float:left; 
    width:230px;
}

.border-top{
    padding-top: 30px;
    padding-left: 30px;
    height: 3px solid #fefdfc;
    width:10px;
    background-color:#fefdfc;
    }
.form-text h3{
    padding-top: 30px;
    padding-left: 30px;
    font-size:20px;
    font-weight:bold;
    color:#fefdfc;

}

label{
    display: block;
    padding-top: 30px;

}
.form-control{
    margin-bottom: 30px;
    border-radius: 0px;
    margin-right: 30px;

}

.contact-form .btn{
    border-radius: 0px;
    margin-top: 24px;
}

.contact-form  .btn-default{
    background-color: #090805;
    border-color: #090805;
    padding-top: 5px;
    color: #fefdfc;
}

.contact-form h3:before {

    width: 4.5%;
    background: none repeat scroll 0 0 #fefdfc;
    border-top: 1px solid #fefdfc;
    content: "";
    height: 5px;
    position: absolute;
    margin-top: -10px;
}

        .icon-bar {
            background-color:violet;

        }

HTML:

<div class="form-container">
            <div class="contact-form">

                <div class="form-text">

                    <h3>Free Advice And Consultation</h3>

                </div>


                <nav class="navbar" role="navigation">
                    <div class="navbar-header">
                        <button style="background-color:aqua" type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                    </div>


                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <div class="form-inline" role="form">

                            <div class="form-group middle-form">
                                <label for="exampleInputEmail2">Name</label>
                                <input type="name" class="form-control" id="exampleInputName" placeholder="Enter name">
                            </div>

                            <div class="form-group middle-form">
                                <label for="exampleInputPhone">Phone</label>
                                <input type="phone" class="form-control" id="exampleInputPhone" placeholder="Phone">
                            </div>

                            <div class="form-group middle-form">
                                <label for="exampleInputEmail2">Email address</label>
                                <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email" />
                            </div>

                            <div class="form-group middle-form">
                                <label for="exampleInputEmail2">Treatment</label>
                                <select class="form-control">
                                    <option>Relaxation Massage</option>
                                    <option>Remedial Massage</option>
                                    <option>Sports Massage</option>
                                    <option>Trigger Point Massage</option>
                                    <option>Float Bath</option>
                                    <option>Infrared Sauna</option>
                                </select>
                            </div>

                            <button type="submit" class="btn btn-default middle-form">Send</button>
                        </div>
                    </div>
                </nav>

            </div>
        </div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-15
    相关资源
    最近更新 更多