jquery跑马灯代码(花式跑马灯代码解析)
admin 发布:2022-12-19 18:40 111
今天给各位分享jquery跑马灯代码的知识,其中也会对花式跑马灯代码解析进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
jquery 跑马灯 怎么 实现 循环
打开 Dreamweaver
新建 HTML 文档;
修改标题为"跑马灯"
保存为 index.html 文件。
jquery跑马灯 图片不间断滚动效果
首先,编写跑马灯部分的静态 HTML 代码,把图片排列起来
在 body 和 /body 标签中添加以下代码:
div
ul
liimg src="img/1.jpg" //li
liimg src="img/2.jpg" //li
liimg src="img/3.jpg" //li
liimg src="img/4.jpg" //li
liimg src="img/5.jpg" //li
liimg src="img/6.jpg" //li
liimg src="img/7.jpg" //li
/ul
/div
jquery跑马灯 图片不间断滚动效果
给上一步的 HTML 代码中的 div 标签增加 class 属性,如下:
div class="con"
编写跑马灯部分的 CSS 样式代码,代码放在 head 和 /head 标签中,如下:
style type="text/css"
ul{list-style:none; padding:0; margin:0;}
.con{ width:1105px; height:225px; overflow:hidden; border:2px solid #666; margin:10px auto 0 auto; padding:5px 0 0 5px;}
.con ul li{ float:left; margin:0 5px 10px 0;}
.con ul li img{ display:block; width:209px; height:209px; padding:2px; border:1px solid #ccc;}
/style
jquery跑马灯 图片不间断滚动效果
引入 JQuery 库
script type="text/javascript" src="jquery-1.11.0.min.js"/script
引入 Marquee 插件
script type="text/javascript" src="marquee2.js"/script
代码放在 /body 标签前,如图:
jquery跑马灯 图片不间断滚动效果
给 div 增加 marquee 类
div class="con marquee"
保存文件,在浏览器中打开,就可以看到图片开始滚动了。
jquery跑马灯 图片不间断滚动效果
图片默认的滚动方向是“向上滚动”
如果要修改图片滚动的方向,可以给 div 指定 direction 属性,属性值可以取:
up 上
down 下
left 左
right 右
jquery跑马灯 图片不间断滚动效果
完整的例子放在百度网盘中,需要的请发邮件到 xdhy_dn@foxmail.com
主题写 “百度经验”。自动回复下载地址
求Jquery或js一行文字跑马灯代码
这个完全是我本人自己真实项目当中的代码
其实不用js 用css3就能完成
代码如下
标签:{
background: -webkit-gradient(linear,left top,right top,color-stop(0, #3CAF5A),color-stop(0.3, #3CAF5A),color-stop(0.5, white),color-stop(0.7, #3CAF5A),color-stop(1, #3CAF5A));
background-clip: text; //文字背景区域
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-fill-color: transparent;
-webkit-animation: slidetounlock 2s linear infinite; //动画执行的参数 第一是 动画执行的名字 第二是所需时间 第三是执行动画的快慢infinite是均速 第四个参数是循环
animation: slidetounlock 2s linear infinite;
}
为了兼容建议把写全 百分比是指动画执行到多少以后执行里面的动画
@keyframes slidetounlock{
0% {
background-position: -2rem 0;
}
80% {
background-position: 1rem 0;
}
100% {
background-position: 2rem 0;
}
}
@-webkit-keyframes slidetounlock{
0% {
background-position: -2rem 0;
}
80% {
background-position: 1rem 0;
}
100% {
background-position: 2rem 0;
}
}
@-moz-keyframes slidetounlock{
0% {
background-position: -1.1rem 0;
}
80% {
background-position: 1rem 0;
}
100% {
background-position: 1.1rem 0;
}
}
@-ms-keyframes slidetounlock{
0% {
background-position: -1.1rem 0;
}
80% {
background-position: 1rem 0;
}
100% {
background-position: 1.1rem 0;
}
}
@-o-keyframes slidetounlock{
0% {
background-position: -1.1rem 0;
}
80% {
background-position: 1rem 0;
}
100% {
background-position: 1.1rem 0;
}
}
之后你只需要设置文字所在容器的宽度就行,用px可以代替rem;可根据自己的需求来修改
最后效果就是
白色会一直从左到右 有点像早期苹果滑动解锁的那种动画,这个可以根据实际需求来修改
求一段网页代码~图片跑马灯效果
使用两个jQuery插件可以满足你的要求。第一个,跑马灯插件jquery.liMarquee,第二个看图浮层的插件pirobox。
html
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"
meta name="viewport" content="width=device-width, initial-scale=1.0"
titlejQuery跑马灯插件/title
link rel="stylesheet" type="text/css" href="css/default.css"
link rel="stylesheet" href="css/liMarquee.css"
style type="text/css"
.str_wrap{
padding-left: 3em;
padding-right: 3em;
background: #fefefe;
height: 10em;
line-height: 2em;
font-size: 1.2em;
}
.str4 .str_item {
font-size:0;
line-height:0
}
.str4 img { opacity:0.8;width:640px;height:450px;border:0;}
.str4 img:hover { opacity:1}
.str4.str_wrap.str_active {
background:#fff;
}
.str2 img { opacity:0.8;width:640px;height:450px;border:0;}
/style
script src="js/jquery1.8.3.min.js" type="text/javascript"/script
link href="css/style.css" class="piro_style" media="screen" title="white" rel="stylesheet" type="text/css" /
script type="text/javascript" src="js/pirobox.js"/script
script type="text/javascript"
$(document).ready(function() {
$().piroBox({
my_speed: 400,
bg_alpha: 0.1,
slideShow : true,
slideSpeed : 4,
close_all : '.piro_close,.piro_overlay'
});
});
/script
style type="text/css"
body{margin:0 0;}
div{float:left;}
#maindiv{width:1920px;height:1080px;background-color:#ccc;}
a{text-decoration:none;}
img{border:0;}
#zhudiv{width:1920px;height:900px;background-color:#002fa7;}
/style
/head
body
div id="maindiv"
div id="zhudiv"
div class="str4 str_wrap"
a class="pirobox_gall" href="img/1.jpg"img src="img/1.jpg"/a
a class="pirobox_gall" href="img/2.jpg"img src="img/2.jpg"/a
a class="pirobox_gall" href="img/3.jpg"img src="img/3.jpg"/a
a class="pirobox_gall" href="img/4.jpg"img src="img/4.jpg"/a
a class="pirobox_gall" href="img/5.jpg"img src="img/5.jpg"/a
a class="pirobox_gall" href="img/6.jpg"img src="img/6.jpg"/a
a class="pirobox_gall" href="img/7.jpg"img src="img/7.jpg"/a
/div
div class="str2 str_wrap"
a class="pirobox_gall" href="img/11.jpg"img src="img/11.jpg"/a
a class="pirobox_gall" href="img/22.jpg"img src="img/22.jpg"/a
a class="pirobox_gall" href="img/33.jpg"img src="img/33.jpg"/a
a class="pirobox_gall" href="img/44.jpg"img src="img/44.jpg"/a
a class="pirobox_gall" href="img/55.jpg"img src="img/55.jpg"/a
a class="pirobox_gall" href="img/66.jpg"img src="img/66.jpg"/a
a class="pirobox_gall" href="img/77.jpg"img src="img/77.jpg"/a
/div
/div
/div
script src="js/jquery.liMarquee.js"/script
script
$(window).load(function(){
var stringEl = $('.str4').liMarquee();
stringEl.trigger('mouseenter');
stringEl.data({scrollamount:150});
stringEl.trigger('mouseleave');
});
$('.str2').liMarquee({
direction: 'right'
});
/script
/body
/html
jquery跑马灯效果
要实现简单的跑马灯效果其实运用html中marquee/marquee标签就可以达到了
基本属性如下:
1.滚动方向direction(包括4个值:up、 down、 left和 right)
2.滚动方式behavior(scroll:循环滚动,默认效果; slide:只滚动一次就停止; alternate:来回交替进行滚动)
3.滚动速度scrollamount(滚动速度是设置每次滚动时移动的长度,以像素为单位)
4.滚动延迟scrolldelay(设置滚动的时间间隔,单位是毫秒)
5.滚动循环loop(默认值是-1,滚动会不断的循环下去)
6.滚动范围width、height
7.滚动背景颜色bgcolor
8.空白空间hspace、vspace
如果想要更多的动画效果,更多选择jquery.marquee.js这款插件——ul里的啥都能滚并自带悬停效果
1.html 中写入ul id="marquee"li/li/ul
2.js中调入$("#marquee").marquee();即可
3.css比较简单,一般自己写,大致如下:
ul.marquee{display:block;line-height:1;position:relative;overflow:hidden;width:400px;height:22px;}
ul.marquee li{ position:absolute;top:-999em;left:0; display:block; white-space:nowrap ;padding:3px5px;text-indent:0.8em;}
4.相关参数如下:
{
yScroll:"top"; // 初始滚动方向 (还可以是"top" 或 "bottom")
showSpeed:850; // 初始下拉速度
scrollSpeed:12; // 滚动速度
pauseSpeed:5000; // 滚动完到下一条的间隔时间
pauseOnHover:true; // 鼠标滑向文字时是否停止滚动
loop:-1; // 设置循环滚动次数 (-1为无限循环)
fxEasingShow:"swing"; // 缓冲效果
fxEasingScroll:"linear"; // 缓冲效果
cssShowing:"marquee-showing"; //定义class event handlers
init:null; // 初始调用函数
beforeshow:null; // 滚动前回调函数
show:null; // 当新的滚动内容显示时回调函数
aftershow:null; // 滚动完了回调函数
}
jquery跑马灯代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于花式跑马灯代码解析、jquery跑马灯代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-03包厢代码(饭店包厢号)[20240503更新]
- 05-03安卓网页代码编辑软件(安卓平台代码编辑器)[20240503更新]
- 05-03垂直多级导航菜单代码(菜单导航栏的代码)[20240503更新]
- 05-03织梦首页下一页代码(织梦搜索框代码)[20240503更新]
- 05-03网页切换图片代码(网页图片切换怎么做)[20240503更新]
- 05-03jquery网站代码(jquery操作html代码)[20240503更新]
- 05-03matlab代码自动排版(matlab自动排版快捷键)[20240503更新]
- 05-03点击图片翻页代码(图片自动翻页)[20240503更新]
- 05-03matlab锐化代码(matlab自己编写锐化函数)[20240503更新]
- 05-03输入日期显示是否的代码(显示当前时间和日期的代码)[20240503更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接