});-下面是更多关于透明的距离的问答
发布于:2020-08-10 06:28
浏览了 63次
1
$(window).scroll(function(){if($("body").scrollTop()>$(window).height()){/*你要的是一屏,知道屏幕多大就用浏览器窗口高度了 在这里以进行你想做的事,变化如果是换字体颜色就是color,背景颜色就是background-color,想换图片就换图片background-image,不一一细说了,写法用$(你的导航栏id或者什么的).css("想要改的样式(如color)","想要改的效果(如#123456)")就行了ps:忘 了还有一个,*/$("h3").css("opacity","0.5");}
最佳贡献者
2
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width">
<title>JS Bin</title><style>.header{ width: 100%; height: 64px; background: rgba(0, 0, 0, .9); color: #FFF; font-size: 32px; text-align: center; position: fixed; top: 0; left: 0; transition: background 1s;}.content{ width: 100%; height: 1000px; position: relative; padding-top: 64px;}.scrolledDown{ background: rgba(0, 0, 0, 0); color: #ddd;}</style><script>(function(){ pos = 0; ticking = false; var header = document.querySelector(".header"); window.addEventListener("scroll", function(e){ pos = window.scrollY; if(pos > 100&&!ticking){ header.classList.add("scrolledDown"); ticking = true; } if(pos < 100 && ticking){ header.classList.remove("scrolledDown"); ticking = false; } });})();</script></head><body> <header class="header"> menu </header> <div class="content"> this is a content </div></body></html> 本回答被网友采纳
3
position:fixed定位试试?
4
打开源代码后找到该窗口,把x坐标和y坐标设置到你想要的地方就可以了~!你没把代码贴出来俺也只能这样说了~!
5
a:visited这个不建议用,因为页面重新来候,它还默认为访问过而active你点击后获取焦点的时候有效。一旦失去焦点就无效了。建js来实现就是对a 做onclick事件,当点击之后,将其样式更换成你需要的,这样就算失去焦点也不会又问题了。
本回答被网友采纳
6
代•$(function(){•//获取要定位元素距离浏览器顶部的距离
•var navH = $(".nav").offset().top;•//条事•$(window).scroll(function(){•//获取滚动条的距离•var scroH = $(this).scrollTop();•//滚动条的滑动距离大于等于定位元素距离浏览器顶部的距离,就固定,反之就不固定•if(scroH>=navH){•$(".nav").css({"position":"fixed","top":0});•}else if(scroH<navH){•$(".nav").css({"position":"static"});•}•})•}) 本回答被网友采纳
7
在第二页需要判断滚动方向 意思是在每次滚动完成后都需要记住scrollTop然后才好判断滚动方向 否则没办法做到向上滚动....
8
百度一下就知道,
9
那你只要在scroll事件里面改变div的属性就好了$('html,body').scroll(function(){ // TODO})