//获取body中的宽度 js处理 $(window).resize(function(){当浏览器窗口改变的时候发生的事件,在这里使用jquery var width_gotop=($("body").innerWidth()-主要内容的宽度)/2-还需要设置离主页面的一点空隙的宽度; $("#gotop").css("right",width_gotop); }); //第二种方法 css的处理 display: block; position: fixed; left: 50%; top: 520px; margin-left: 525px; z-index: 100; text-align: center; cursor: pointer;