向下滚动网页时如何调整图像(徽标)的大小
how can i resize image(logo) when scroll down the web page
如何反转此功能,我想在向下滚动网页时调整图像(站点徽标)元素的大小(更小)并在滚动到页面顶部时返回
我试过这个:
$(window).on("scroll", function() {
var s = Math.min(400, $(document).scrollTop()) + 100;
$("img").width(s).height(s);
});
但反之亦然。抱歉我的英语写作问题。
前面加个前缀尺寸:
$(window).on("scroll", function() {
var s = 400 - Math.min(400, $(document).scrollTop());
$("img").width(s).height(s);
});
根据您的需要调整 400
。 :)
Fiddle: http://jsfiddle.net/pur9ruut/
如何反转此功能,我想在向下滚动网页时调整图像(站点徽标)元素的大小(更小)并在滚动到页面顶部时返回
我试过这个:
$(window).on("scroll", function() {
var s = Math.min(400, $(document).scrollTop()) + 100;
$("img").width(s).height(s);
});
但反之亦然。抱歉我的英语写作问题。
前面加个前缀尺寸:
$(window).on("scroll", function() {
var s = 400 - Math.min(400, $(document).scrollTop());
$("img").width(s).height(s);
});
根据您的需要调整 400
。 :)
Fiddle: http://jsfiddle.net/pur9ruut/