当前位置: 首页 > news >正文

太原网站推广怎么做/网址链接生成器

太原网站推广怎么做,网址链接生成器,1000元能否做网站,泰州网站建设价位演示地址:http://www.jq22.com/jquery-info1799 jquery插件,使用验证过可用。 分析源代码后总结原理:设置background样式为fixed,判断浏览器滚动距离,当在视窗范围内时,调用$(window).scroll。并根据所设置…

演示地址:http://www.jq22.com/jquery-info1799

 

jquery插件,使用验证过可用。

分析源代码后总结原理:设置background样式为fixed,判断浏览器滚动距离,当在视窗范围内时,调用$(window).scroll。并根据所设置的速度比例,进行同步滚动。

调用时,设置三个必要参数:data-speed,data-type,background样式为fixed

<div data-speed="4" data-type="background" style="background:url(...) 50% 0 no-repeat fixed">    

js会根据data-speed来计算滚动速度,越小越快。

可以根据不同的data-type作不同处理,可自定义写代码,很方便。

background必须是fixed。

 

parallax.js源代码(需先引入jQuery)

 

$(document).ready(function(){// Cache the Window object$window = $(window);// Cache the Y offset and the speed of each sprite$('[data-type]').each(function() {    $(this).data('offsetY', parseInt($(this).attr('data-offsetY')));$(this).data('Xposition', $(this).attr('data-Xposition'));$(this).data('speed', $(this).attr('data-speed'));});// For each element that has a data-type attribute$('section[data-type="background"]').each(function(){// Store some variables based on where we arevar $self = $(this),offsetCoords = $self.offset(),topOffset = offsetCoords.top;// When the window is scrolled...$(window).scroll(function() {// If this section is in viewif ( ($window.scrollTop() + $window.height()) > (topOffset) &&( (topOffset + $self.height()) > $window.scrollTop() ) ) {// Scroll the background at var speed// the yPos is a negative value because we're scrolling it UP!                                var yPos = -($window.scrollTop() / $self.data('speed')); // If this element has a Y offset then add it onif ($self.data('offsetY')) {yPos += $self.data('offsetY');}// Put together our final background positionvar coords = '50% '+ yPos + 'px';// Move the background
                $self.css({ backgroundPosition: coords });// Check for other sprites in this section    $('[data-type="sprite"]', $self).each(function() {// Cache the spritevar $sprite = $(this);// Use the same calculation to work out how far to scroll the spritevar yPos = -($window.scrollTop() / $sprite.data('speed'));                    var coords = $sprite.data('Xposition') + ' ' + (yPos + $sprite.data('offsetY')) + 'px';$sprite.css({ backgroundPosition: coords });                                                    }); // sprites// Check for any Videos that need scrolling$('[data-type="video"]', $self).each(function() {// Cache the videovar $video = $(this);// There's some repetition going on here, so // feel free to tidy this section up. var yPos = -($window.scrollTop() / $video.data('speed'));                    var coords = (yPos + $video.data('offsetY')) + 'px';$video.css({ top: coords });                                                    }); // video    
            }; // in view
    }); // window scroll
            });    // each data-type

}); // document ready

 

转载于:https://www.cnblogs.com/woodk/p/4808155.html

http://www.lbrq.cn/news/1557865.html

相关文章:

  • 珠海专业做网站的公司/百度主页
  • 网站推广优势/产品网络推广方案
  • 网站title在哪里/网上营销是做什么的
  • 二级网站建设方案模板/深圳aso优化
  • 深圳网站建设app开发/广西关键词优化公司
  • 用自己网站做淘宝客/百度云盘资源搜索
  • 做微网站用什么框架/网络营销自学网站
  • seo一级域名和二级域名/长沙网站优化培训
  • 做方案的网站/唐山网站建设方案优化
  • 宁波建设网站/比优化更好的词是
  • 开发帮官方网站/营销推广计划怎么写
  • 深圳龙华新区住房和建设局网站/营销推广活动策划
  • 乌鲁木齐企业网站建设/上海整站seo
  • 怎么做百度搜到的网站免费的/可以发外链的平台
  • 连锁酒店网站建设公司/国内seo做最好的公司
  • 大连网站建设1000元/公关
  • 网页设计专业设计课程/百度优化软件
  • 如何做一个个人网站/网站推广策划书范文
  • 南通企业网站/企业网站有哪些平台
  • 什么东西可以做网站/网络营销文案策划都有哪些
  • 公司注册查重名/百度网站优化公司
  • 国企门户网站建设方案/广州网站运营专注乐云seo
  • wordpress需要调用缩略图/北京seo公司助力网络营销
  • 九龙坡网站建设哪家好/在线培训网站
  • 大门户wordpress主题门户新闻/seo搜索引擎优化策略
  • 域名及对应网站/成都官网seo服务
  • 做一个网站只做前端怎么做/百度竞价推广是什么意思
  • 苹果电脑如何做网站/网站制作公司排名
  • 做结构图用什么网站/长春网络优化最好的公司
  • 怎么做单页网站导航/怎么开发自己的小程序
  • 逆向Shell实战——红队技巧 vs 蓝队防御全攻略
  • PyCharm与前沿技术集成指南:AI开发、云原生与大数据实战
  • TOGAF八步一法笔记2
  • 【Twincat3】IO的SCAN 不可选中,SCAN中后扫描不到设备
  • SaltStack 基础
  • 【JavaEE】多线程 -- 死锁问题