lilelile

两种方法都能够实现:

1.

div {  
  height:80%; /*一定要设置高度*/ 
 overflow:hidden;/*建议设置*/ margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }

2.

div{  
   position: absolute;  
   width: 80%;  
   height: 60%;  
   padding: 2%;   
   top: 50%;
   left: 50%;  
   margin-left: -41%;  /* (width + padding)/2 */  
   margin-top: -31%;  /* (height + padding)/2 */  
}     

  

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2022-01-06
  • 2021-11-10
  • 2021-11-30
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
  • 2021-06-17
  • 2021-11-30
  • 2021-08-01
  • 2021-11-30
相关资源
相似解决方案