2015-09-04 10 views
0

我正在使用<div>,我想使其成爲position: fixed。我已經添加CSS規則position:fixed但在添加之後<div>縮小。使用位置時,div會縮小:固定

enter image description here

enter image description here

請指引我到這一點。

我的HTML代碼是這樣

<div layout="row" style="background-color:#1CA5EA; position:fixed"> 

    <div offset="25" flex="30" class="input-container"> 
     <md-input-container flex > 
      <label style="color:white">Search</label> 
      <input ng-model="search" style="border-bottom:2px solid white;color:white;"> 
     </md-input-container> 
    </div> 

    <div flex="10" class="input-container"> 
     <button class="primary-button md-button md-default-theme"> 
     <span class="ng-scope" ui-sref="company.addRecruitmentProject"> 
      + JOB AD 
     </span> 
     </button> 
    </div> 

</div> 
+1

添加相關的HTML和CSS代碼在這裏。 –

+0

@SrinivasPai我在這裏添加了代碼。 –

+0

哪裏是CSS? –

回答

1

使用該專區width:100%;

<div layout="row" style="background-color:#1CA5EA; position:fixed; width:100%;"> 

    <div offset="25" flex="30" class="input-container"> 
     <md-input-container flex > 
      <label style="color:white">Search</label> 
      <input ng-model="search" style="border-bottom:2px solid white;color:white;"> 
     </md-input-container> 
    </div> 

    <div flex="10" class="input-container"> 
     <button class="primary-button md-button md-default-theme"> 
     <span class="ng-scope" ui-sref="company.addRecruitmentProject"> 
      + JOB AD 
     </span> 
     </button> 
    </div> 

</div> 

Demo here

0

可能是其他分區或元素的HTML作出股利影響。這就是爲什麼你的div被縮小。其次請在這裏添加你的CSS代碼,然後我可以有希望解決你的問題。

0

在這種情況下,您應該定義您的位置固定的<div>的寬度。 比方說,例如:

.div { 
    width: 80%; // or whatever you want to be the size 
}