使用如下css可以使div永远保持在屏幕正中

代码
<style type="text/css">

.log
{
position
:absolute; /*绝对定位*/
top
:50%; /*距顶部50%*/
left
:50%;
margin
:-100px 0 0 -150px; /*设定这个div的margin-top的负值为自身的高度的一半,margin-left的值也是自身的宽度的一半的负值.(感觉在绕口令)*/
width
:300px; /*宽为400,那么margin-top为-200px*/
height
:200px; /*高为200那么margin-left为-100px;*/
z-index
:99; /*浮动在最上层 */
}
</style>

 

相关文章:

  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-12-12
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2022-12-23
  • 2022-01-15
  • 2021-03-29
  • 2022-01-18
  • 2021-07-01
  • 2022-12-23
  • 2021-05-27
相关资源
相似解决方案