1.利用jquery居中代码

<script type="text/javascript">
$hwidth=parseInt($(window).width());

$margin=($hwidth-960)/2;/*假定需要居中的块的宽度为960px*/
    $('.er').css('margin-left',$margin+'px');
    
</script>

2.利用$('html')取得的宽度比$(window)小

$('html')取得的宽度不能用做居中依据的计算值

 

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-09-03
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
相关资源
相似解决方案