css解决fixed布局不会出现滚动条

css解决fixed布局不会出现滚动条的问题

如果我们布局的是后是fixed并且想要高度为100%的时候,我们一般会这样设置:

width : 100% ;
height : auto ;
z-index : 9999999 ;
background : #fff ;
padding-bottom : 1rem ;
position : fixed ;
top : 0 ;
overflow-y : scroll ;
overflow-x : hidden ;

但是这样并不会出现滚动条,正确的做法应该设置top和bottom为0:
  1. .fixed-content {  
  2.     top: 0;  
  3.     bottom:0;  
  4.     position:fixed;  
  5.     overflow-y:scroll;  
  6.     overflow-x:hidden;  
  7. }  

猜你喜欢

转载自blog.csdn.net/ch834301/article/details/80771831