如何在旋转木马顶部放置搜索框?

时间:2014-03-28 17:22:59

标签: jquery css html5 twitter-bootstrap carousel

我想制作类似airbnb

的内容

这是我使用twitter bootstrap的轮播代码。

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
             <!-- Indicators -->
    <ol class="carousel-indicators">
         <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
         <li data-target="#carousel-example-generic" data-slide-to="1"></li>
         <li data-target="#carousel-example-generic" data-slide-to="2"></li>
    </ol>


     <!-- Wrapper for slides -->
    <div class="carousel-inner">
        <div class="item active">
          <img src="rio.jpg" alt="">
        </div>
        <div class="item">
          <img src="rio.jpg" alt="">
        </div>
        <div class="item">
          <img src="rio.jpg" alt="">
        </div>  
    </div>
    <!-- Controls -->
   <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
       <span class="glyphicon glyphicon-chevron-left"></span>
   </a>
   <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
       <span class="glyphicon glyphicon-chevron-right"></span>
   </a>
</div>

这是我创建的表单布局。

    <div class="form-group">    
        <div class="container">
            <div class="row">
            <div class="col-md-6">
                <input type="text" class="form-control input-lg" placeholder="Where do you wanna go?">  
            </div>
            <div class="col-md-2">
                <input type="date" class="form-control input-lg" name="start" placeholder="Check In">   
            </div>
            <div class="col-md-2">
                <input type="date" class="form-control input-lg" name="end" placeholder="Check Out">            
            </div>
            <div class="col-md-2">
                <a class="btn btn-lg btn-success" href="#" role="button">GO</a>
            </div>
            </div>
        </div>
    </div>

这是我尝试过的。

.form-group{
   margin-top: -250px;
}

但它没有用。请帮帮我。

1 个答案:

答案 0 :(得分:1)

移动&#34;表格组&#34; div到旋转木马div的顶部。像这样:

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <div class="form-group">    
    ....
    </div>
    other carousel html here...
</div>

然后添加此css:

div#carousel-example-generic {
    position:relative;
}

div.form-group {
    position:absolute;
    z-index:9999999;
    top:20px; /* change to whatever you want */
    left:10px; /* change to whatever you want */
    right:auto; /* change to whatever you want */
    bottom:auto; /* change to whatever you want */
}

这适用于所有浏览器(IE6 +)。