Home > Web Front-end > JS Tutorial > Sample code similar to Tmall product details moving with the browser_jquery

Sample code similar to Tmall product details moving with the browser_jquery

WBOY
Release: 2016-05-16 16:57:53
Original
1179 people have browsed it

To use this function, it must be integrated into the jquery package

Principle: When the browser moves to a specified position, the layer floats up, and then a style is added to position the div layer at the top of the browser

Copy code The code is as follows:

//Control the display of the head shopping 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");
};
});
};

Copy code The code is as follows:

.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 labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template