.afix{
position:fixed; top:45px; z-index:100; } .fix{ position:fixed; top:0px; z-index:100; }.parent {
background: white; width: 100%; border-bottom: 1px solid #FFF; }window.οnscrοll= function(){
//变量t是滚动条滚动时,距离顶部的距离//var current =document.documentElement.scrollTop;var currnet = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
var obj = $('.parent')[0]; var hig =$('#source_container').height(); var isAndroid = u.indexOf('Android') > -1|| u.indexOf('Linux') > -1; var css ='fix'; if(isAndroid){ css = 'afix'; } if(hig-current<50){ var obj = $('.parent')[0]; $(obj).addClass(css);// ('position','fixed'); }else{ if($(obj).hasClass(css)) { $(obj).removeClass(css); } }}
<div class="div_body topcss">
<div class="xuanfu"> <div id="source_container"> </div> <div class="parent"> <div class="sui"><i class="fa fa-user-circle-o" aria-hidden="true"></i><input class="weui-btn_primary weui-input " type="button" value="我也来说两句" id="comment"></div> </div> </div> <div class="container"> @*<div class="comentcss"><a href="#" id="more">查看更多</a></div>//这个功能去掉*@ </div></div>