Sample code that looks like Tmall product details moving with the browser

  • 2020-03-30 02:08:38
  • OfStack

To use this function, you must integrate it into the jquery package

How it works: when the browser moves to a specific location, the layer floats up, then adds a style that positions the div layer at the top of the browser
 
//Control the display of head cart
function fixshow(min_height){ 
min_height ? min_height = min_height : min_height = 830; 
$(window).scroll(function(){ 
var s = $(window).scrollTop(); 
if( s > min_height){ 
$("#proBuyTip").fadeIn(100); 
$(".fixtabwrap").addClass("topfixed"); 
}else{ 
$("#proBuyTip").fadeOut(200); 
$(".fixtabwrap").removeClass("topfixed"); 
}; 
}); 
}; 

 
.topfixed { 
position: fixed !important; 
top: 0px; 
left: 0px; 
z-index: 999; 
width: 100%; 
background-color: white; 
position: absolute; 
_top: expression(eval(document.documentElement.scrollTop)); 
} 

Related articles: