导航:首页 > 编程语言 > 滑动导航栏js代码

滑动导航栏js代码

发布时间:2021-02-27 20:01:18

⑴ 求一个js代码,导航条在网页向下拉动时始终在屏幕顶端显示

不需要JS你可以用CSS固定定位 position:fixed 注意该属性在IE6下没用

⑵ 求个JS代码关于滑动门的。由于数据多导航栏溢出,所以求个左右可以滑动的按钮

网上找个无缝滚动的代码. 改改就能实现你所说的效果..

我这些给你写了个类似的代码 但是没有你要求的那种.你看看有没有用吧

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>newdocument</title>
<metaname="generator"content="editplus"/>
<metaname="author"content=""/>
<metaname="keywords"content=""/>
<metaname="description"content=""/>

<style>
.main{width:600px;padding:0auto;}
.tabs{width:100%;}

.tabs.left{
width:9%;
float:left;
border:1pxsolid#ddd;
line-height:32px;
}
.tabs.center{
width:80%;
float:left;
border:1pxsolid#ddd;
overflow:hidden;
height:32px;
line-height:32px;
}
.tabs.center.tab{
width:12%;
float:left;
border:1pxsolid#ddd;
display:inline-block;
line-height:32px;

}
.tabs.center.hide{
display:none;
}
.tabs.right{
width:10%;
float:right;
border:1pxsolid#ddd;
line-height:32px;
}


</style>

<scriptsrc="jquery.min.js"></script>
<script>

$("document").ready(function(){
$(".tabs").each(function(){
var_this=$(this);
$(this).find(".left").click(function(){
vartabs=$(".center>.hide");
if(tabs.length>0)
{
tabs.last().removeClass("hide");
}
});
$(this).find(".right").click(function(){
varcenter=_this.find(".center");
vartabs=center.children();
varfirst=null;
tabs.each(function(){
if($(this).attr("class").indexOf("hide")>0)
{
first=$(this);
}
})
if(first==null)
{
tabs.first().addClass("hide");;
}
else
{
first.next().addClass("hide");
}

});
})

})
</script>
</head>

<body>
<divclass="main">
<divclass="tabs">
<divclass="left">&lt;&lt;</div>
<divclass="center">
<divclass="tab">1</div>
<divclass="tab">2</div>
<divclass="tab">3</div>
<divclass="tab">4</div>
<divclass="tab">5</div>
<divclass="tab">6</div>
<divclass="tab">7</div>
<divclass="tab">8</div>
<divclass="tab">9</div>
<divclass="tab">10</div>
</div>
<divclass="right">&gt;&gt;</div>
</div>
</div>
</body>
</html>

⑶ 页面实现滑动JS代码

js实现随页面滑动效果的方法。具体如下:
页面向上向下滚动,分享到的模块随着滑动。

要点:
代码如下:
var scrtop =document.documentElement.scrollTop||document.body.scrollTop;
var height = document.documentElement.clientHeight||document.body.clientHeight;
var top = scrtop + (height - jb51.offsetHeight)/2;
top = parseInt(top);

获得页面垂直居中的位置

上代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312" />
<title>无标题文档</title>
<style>
body{margin:0; padding:0; font:12px/1.5 arial; height:2000px;}
#jb51{width:100px; height:200px; line-height:200px;
text-align:center; border:1p solid #ccc;
background:#f5f5f5; position:absolute; left:-100px; top:0;}
#jb51_tit{position:absolute; right:-20px; top:60px;
width:20px; height:60px; padding:10px 0;
background:#06c; text-align:center;
line-height:18px; color:#fff;}
</style>
<script>
window.onload = function(){
var jb51 = document.getElementById("jb51");
jb51.onmouseover = function(){
startrun(jb51,0,"left")
}
jb51.onmouseout = function(){
startrun(jb51,-100,"left")
}
window.onscroll = window.onresize = function(){
var scrtop=document.documentElement.scrollTop||document.body.scrollTop;
var height=document.documentElement.clientHeight||document.body.clientHeight;
var top = scrtop + (height - jb51.offsetHeight)/2;
top = parseInt(top);
startrun(jb51,top,"top")
}
}
var timer = null
function startrun(obj,target,direction){
clearInterval(timer);
timer = setInterval(function(){
var speed = 0;
if(direction == "left"){
speed = (target-obj.offsetLeft)/8;
speed = speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.offsetLeft == target){
clearInterval(timer);
}else{
obj.style.left = obj.offsetLeft + speed + "px";
}
}
if(direction == "top"){
speed = (target-obj.offsetTop)/8;
speed = speed>0?Math.ceil(speed):Math.floor(speed);
if(obj.offsetTop == target){
clearInterval(timer);
}else{
obj.style.top = obj.offsetTop + speed + "px";
}
document.title = obj.offsetTop + ',' + target + ',' +speed;
}
},30)
}
</script>
</head>
<body>
<div id="jb51">
分享到内容
<span id="jb51_tit">分享到</span>
</div>
</body>
</html>

⑷ 求教用js(jquery)实现点击按钮使导航菜单水平滑入滑出界面

用动画写就行啦
animate()
改变它的定位

⑸ 求个JS代码关于滑动门的。由于数据多导航栏溢出,所以求个左右可以滑动的按钮。

很简单嘛,偶现在给你写一个,给我你的邮箱

⑹ 网页导航栏随着页面下拉而逐渐保持在网页顶部的js代码及原理

获取那个导航DIV的top坐标,然后判断滚动条大于或等于top坐标的参数就给导航DIV添加position:fixed;top:0;样式就可以了反过来就是删除这些样式

⑺ 导航栏的js 代码按照下面的东西怎么写急求啊

// 用JQ实现 没测试,楼主自行修改 大致就是鼠标进入h3的时候 对应下面的ul会展开
(function (){
var $nav = $("#navul").children(),
timer = null;

$nav.each(function(){
var $me = $(this);

if ($me.find('h3')) {
$me.find('h3').mouseenter(function(){
$me .find('ul').sildeDown();
}).mouseleave(function(){
timer = setTImeout(function () {
$me .find('ul').sildeUp();
}, 500);
});
}

$me .find('ul').mouseenter(function(){
clearTimeout(timer);
}).mouseleave(function () {
$(this).sildeUp();
});
});

})();

⑻ HTML5 滑动条js代码怎么写

强大的抄HTML5提供了一种新的标签<progress>,只需要通袭过该标签+简单的js,即可以实现进度条滚动的效果。

代码如下:

HTML

1<progressmax="100" value="0" id="pg"></progress>

这个标签意义很明确,并且属性只有以上两个,max表示需要完成的任务量,value是目前完成的任务量。

js

12345varpg=document.getElementById('pg');setInterval(function(e){if(pg.value!=100) pg.value++;elsepg.value=0;},100);

以上的实现方式不仅更加的语义化,同时也极大的简化了我们的代码,并且灵活性更高,所以熟练使用HTML5是非常有必要的!

不过HTML5标签的浏览器兼容性也是我们需要考虑的一个问题,所以如果网页需求的兼容性比较高的话,特别是对低版本IE有兼容需求的话,那么HTML5的标签就不太适用了。以下为<progress>的浏览器支持情况。

⑼ 如何用JS代码编写导航栏的翻页效果

你要的是这个效果么,这个效果可以在开创者素材里面免费下载的

⑽ 如何用tween.js实现导航条滑动

.content { width:960px; height:2024px; border:1px solid #000; margin:0 auto;}.nav { width:100%; height:30px; margin:0 auto; background:#f00; position:fixed; bottom:0; text-align:center;}导航

阅读全文

与滑动导航栏js代码相关的资料

热点内容
柏林漂流 浏览:930
求一个在线看片网址 浏览:566
泰国女同尺度大电影 浏览:36
日本风月片 浏览:620
广州中宇恒达网络技术有限公司 浏览:187
答题辅助工具 浏览:762
如何保存excel中嵌入的文件 浏览:950
襄阳哪个编程公司 浏览:971
中国盗墓电影全部 浏览:415
一女嫁多个兄弟的小说 浏览:920
学校出台文件从哪里找 浏览:536
部落电影推荐 浏览:12
火影之另样的活着苹果鸭梨汁小说 浏览:718
华为怎么下载壮观app 浏览:710
绘画工具介绍 浏览:692
韩国一个女钢琴家个一个学生 浏览:860
dianyinggo 浏览:581
主角姓秦天的都市小说 浏览:442
李彩谭演的电影 浏览:826
重生晚清军阀系列小说 浏览:207

友情链接