relative(相對定位) 對象不可層疊、不脫離文檔流,參考自身靜態位置經過top,bottom,left,right定位,而且能夠經過z-index進行層次分級app
absolute(絕對定位) 脫離文檔流,經過top,bottom,left,right定位。選取其最近一個最有定位設置的父級對象進行絕對定位,若是對象的父級沒有設置定位屬性,
absolute元素將以body座標原點進行定位,能夠經過z-index進行層次分級。 .net
fixed(固定定位) 這裏所固定的參照對像是可視窗口而並不是是body或是父級元素。可經過z-index進行層次分級。orm
static:無特殊定位,對象遵循正常文檔流對象
Adiv是放在Bdiv上面的,而且屏幕小的時候各個文本框就單獨佔一行以下:文檔
這時須要用到position :relatic實現,get
<div class="row searchRow" style="">
<div class="col-lg-4 margin_b20" style="">
<div class="floatLeft zhangdan-time-title ">開始時間:</div>
<div class="zhangdan-time" style=""><input type="text" value="" class="form-control" id="appDate1" ></div>
</div>
<div class="col-lg-4 margin_b10" style="">
<div class="floatLeft zhangdan-time-title ">結束時間:</div>
<div class="zhangdan-time" style=""><input type="text" value="" class="form-control" id="appDate2" ></div>
</div>
<div class="col-lg-2 margin_b10">
<button class="btn btn-primary" ><i class="fa fa-search"></i>查詢</button>
</div>
</div>input
/*自適應搜索*/
.floatLeft {float: left;}
.zhangdan-time-title{height:34px;line-height:34px;}
.zhangdan-time{margin-left:80px;}
.searchRow{position:absolute;z-index:999;width:900px;margin-top:10px;}
@media (max-width: 1200px){
.searchRow{position:static;width:100%;margin-left:0;margin-right:0;}
.searchRow>div{padding-left:0;padding-right:0;}
}itposition:absolute 所在div外面的div也沒有必要定義position:relative,此裏面的div 可使用margin來定位,當屏幕小的時候迴歸正常文檔流position:staticio