相关文章推荐
有腹肌的卡布奇诺  ·  js ...·  1 月前    · 
旅途中的小熊猫  ·  JavaScript 之 ...·  1 月前    · 
虚心的海龟  ·  Unreal Engine4 ...·  1 年前    · 
高大的泡面  ·  npm ...·  2 年前    · 
-webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); background: url(../Images/notice.png) left 10px center no-repeat; #scroll_begin li, #scroll_end li { line-height: 32px; text-indent: 30px;
/*新闻滚动*/
$(function () {
    var $this = $(".noticeMsg");
    var scrollTimer;
    //hover()方法的含义是鼠标滑入滑出,它对应着两个事件,即mouseenter和mouseleave,因此可通过trigger("mouseleave")来触发hover事件的第二个函数
    $this.hover(
        function () {
            clearInterval(scrollTimer);
        function () {
            scrollTimer = setInterval(function () {
                scrollNews($this);
            }, 3000);
    ).trigger("mouseleave");//当用户进入页面后就会触发hover事件的第二个函数,从而使内容滚动起来
function scrollNews(obj) {
    var $self = obj.find("ul:first");
    var lineHeight = $self.find("li:first").height();
    $self.animate({"marginTop": -lineHeight + "px"}, 600, function () {
        //把所有匹配的元素追加到$self元素的后面,所以才出现这种周而复始滚动的效果
        $self.css({marginTop: 0}).find("li:first").appendTo($self);

二:横向滚动效果
1.CSS

#scroll_noticeMsg {height:26px;overflow: hidden;white-space: nowrap;width:535px;margin-left:10px;}
#scroll_begin,#scroll_end {display: inline;}
//文字横向滚动
function ScrollImgLeft(){ 
 var speed=50;
  var MyMar = null;
 var scroll_begin = document.getElementById("scroll_begin"); 
 var scroll_end = document.getElementById("scroll_end"); 
 var scroll_div = document.getElementById("scroll_noticeMsg"); 
 scroll_end.innerHTML=scroll_begin.innerHTML; 
 function Marquee(){ 
  if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0) 
   scroll_div.scrollLeft-=scroll_begin.offsetWidth; 
   scroll_div.scrollLeft++; 
  MyMar=setInterval(Marquee,speed); 
  scroll_div.onmouseover = function(){
       clearInterval(MyMar);
     scroll_div.onmouseout = function(){
       MyMar = setInterval(Marquee,speed);     
ScrollImgLeft();
                    一:竖向滚动效果 1.html &lt;div id=&quot;scroll_noticeMsg&quot; class=&quot;noticeMsg&quot;&gt;      &lt;ul id=&quot;scroll_begin&quot;&gt;        &lt;li&gt;数据一&lt;/li&gt;        &lt;li&gt;数据二&lt;/li&gt;        &lt;li&gt;数据三&lt;/li&gt;        &lt;li&gt
2.编写动画滚动方法接收显示广告图片索引,并执行动画移动到指定广告图片,并重置当前中的图片序号效果。
3.为图片序号设置鼠标移动事件,并调用显示图片的方法切换广告图片。
4.为广告图片编写鼠标移入事件,当鼠标移入时,停止自动切换广告图片时钟(定时器)。
5.为广告图片编写鼠标移出事件,当鼠标移出的时后,启动时钟自动每2秒切换...
				
实现js的垂直滚动首先要先搞懂offsetTop和scrollTop的两个属性offset属性介绍 http://www.cftea.com/c/2009/01/R3MW6VH4GID77IZV.asp scroll属性介绍 http://www.codesky.net/article/201004/99238.html 从以上两篇文章中可以大致将offsetTop理解为内部边框的
scroll: -1, //定时器中使用。当表格滚动完了自动从第一条数据开始重复滚动 speed: 100, //定时器执行时间间隔 myInterval: “”, //设置定时器 在mounted里面别忘了开始方法 mounted() { <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>列表无缝滚动</title> </head> <style> <div class="llbr_01"> <div><a href="#" target="_blank" style="color:red;">英雄</a></div> <div id="marquee1" style="width:468px;height: 38px;float: left;overflow: hidden;"> <div style="widt