2017-10-10 79 views
-1

我试图使height: 100%;使用div,但背景需要有一个固定的位置。溢出-y不能使用固定位置

我试图使用box-sizing:border-box;像某人回答类似我的问题,但这不适合我。此外,我试图使用绝对位置,但仍然是一样的。

这里是我的CSS

.backgroundIdKlupa { 
position:fixed; 
padding: 0; 
z-index: 999999; 
margin-bottom: 45px; 
} 
.backgroundIdKlupa_tablica { 
background-color: grey; 
top: 0; 
bottom:0; 
position:fixed; 
overflow-y:scroll; 
overflow-x:hidden; 
} 
.idKlupa_tablica { 
height: 90%; 
font-size: 14px; 
font-weight: bold; 
margin-bottom: 45px; 
} 
.backgroundIda { 
background-color: green; 
width: 100%; 
height: 550px; 
} 

的Html

<div class="backgroundIdKlupa col-lg-1 col-md-1 col-sm-2 col-xs-12"> 
      <table class="backgroundIdKlupa_tablica table-hover"> 
       <thead> 
        <tr> 
         <th class="backgroundIdKlupa_izbornik_th">Bench ID</th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
        <td class="aktivniItem backgroundIdKlupa_izbornik_td" >123</td> 
        </tr> 
        <tr> 
        <td class="aktivniItem backgroundIdKlupa_izbornik_td" >123</td> 
        </tr> 
        <tr> 
        <td class="aktivniItem backgroundIdKlupa_izbornik_td" >123</td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 
     <div class="backgroundIda col-lg-1 col-md-1 col-sm-2 col-xs-12"></div> 

左边的菜单需要修复,但如果有更多的项目,需要有溢出-Y:汽车

权内容(绿色)是正常的。 Thnx

回答

1
For add scroll in any element you need to add height or max-height. second this is a table so make it a block element by using display:block 

backgroundIdKlupa_tablica { 
    background-color: grey; 
    top: 0; 
    bottom: 0; 
    position: fixed; 
    overflow-y: scroll; 
    overflow-x: hidden; 
    height: 50px; 
    display: block; 
} 
+0

谢谢你Ankit Awasthi。这项工作,但为了身高,我需要增加身高:100%;但百分比不起作用。 – Arter

+1

.backgroundIdKlupa_tablica { \t \t \t \t background-color:gray; \t \t \t \t top:0; \t \t \t \t bottom:0; \t \t \t \t position:fixed; \t \t \t \t overflow-y:auto; \t \t \t \t overflow-x:hidden; \t \t \t \t身高:100%; \t \t \t \t display:block; \t \t \t \t}这里工作对我来说只是补充充足行的表 –