WEB前端jQuery漂浮广告代码

释放双眼,带上耳机,听听看~!
00:00
00:00
jQuery漂浮广告代码,很经典的浮动广告,到目前都还很实用,如果你是一位站长的话,这种代码是必备的,希望对你有用处。用jQuery兼容性好,可关闭,鼠标移动在上面时可关闭 ,可控制漂浮速度,稍微改改样式和图片就可使用。
  1. <html>
  2. <head>
  3. <meta charset="gb2312">
  4. <meta name="format-detection" content="telephone=no" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <title>jQuery漂浮广告代码title>
  7. <style type="text/css">
  8. * {
  9. margin: 0px;
  10. padding: 0px;
  11. }
  12. body {
  13. font-size: 12px;
  14. font-family: "微软雅黑";
  15. color: #666;
  16. }
  17. .conent {
  18. width: 90px;
  19. height: 120px;
  20. position: absolute;
  21. top: 20px;
  22. z-index:99999999999999;
  23. }
  24. .conent .sition {
  25. width: 90px;
  26. height: 120px;
  27. position: relative;
  28. }
  29. .conent .sition .c_adver {
  30. width: 90px;
  31. height: 90px;
  32. }
  33. .conent .sition .c_adver img {
  34. width: 90px;
  35. height: 90px;
  36. }
  37. .conent .close {
  38. width: 16px;
  39. height: 16px;
  40. line-height: 14px;
  41. font-size: 16px;
  42. cursor: pointer;
  43. text-align: center;
  44. color: #000;
  45. border: 1px solid #000;
  46. border-radius: 100px;
  47. position: absolute;
  48. top: -10px;
  49. right: -6px;
  50. }
  51. style>
  52. head>
  53. <body>
  54. <div class="conent">
  55. <div class="sition">
  56. <div class="c_adver">
  57. <a href="#" target="_blank"><img src="/image/b.jpg">a>
  58. div>
  59. <span class="close">Xspan>
  60. div>
  61. div>
  62. <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js">script>
  63. <script type="text/javascript">
  64. $(function(){
  65. var timer=null;  //定时器
  66. var _left=0;    //默认left距离
  67. var _top=20;   //默认top距离
  68. var top_folg=false;/*控制高度-锁*/
  69. var left_folg=true;/*控制宽度-锁*/
  70. //获取并计算浏览器初始宽度
  71. var win_width=$(window).width()-$(".conent").width();
  72. //获取并计算浏览器初始高度
  73. var win_height=$(window).height()-$(".conent").height();
  74. $("#liulan").html(win_height+"px");
  75. $("#sumwid").html(win_width+"px");
  76. action();//执行走动
  77. $(".conent").mouseover(function(){
  78. clearInterval(timer);
  79. }).mouseout(function(){
  80. action();
  81. });
  82. $(window).resize(function(){
  83. conobj=$(".conent");
  84. win_width=$(window).width()-conobj.width();
  85. win_height=$(window).height()-conobj.height();
  86. $("#liulan").html(win_height+"px");
  87. $("#sumwid").html(win_width+"px");;
  88. });
  89. function action(){
  90. timer=setInterval(function(){
  91. if(!top_folg){
  92. _top++;
  93. if(_top>=win_height){top_folg=true;};
  94. }else{
  95. _top--;
  96. if(_top<=0){top_folg=false;};
  97. };
  98. if(left_folg){
  99. _left++;
  100. if(_left>=win_width){left_folg=false;};
  101. }else{
  102. _left--;
  103. if(_left<=0){left_folg=true;};
  104. };
  105. $("#textone").html(_top+"px");
  106. $("#timewid").html(_left+"px");
  107. $(".conent").animate({
  108. left:_left,
  109. top:_top
  110. },1);//数字越大,速度越慢
  111. },15);
  112. };
  113. //点击关闭
  114. $(".conent .close").click(function(){
  115. $(this).parents(".conent").slideDown(500,function(){
  116. $(this).remove();
  117. clearInterval(timer);
  118. });
  119. });
  120. });
  121. script>
  122. body>
  123. html>
  124.  
内容投诉
前端开发

使用用jquery做的弹幕特效

2018-11-5 10:28:44

前端开发

ajax同步模式和异步模式的区别

2018-11-5 14:57:56

0 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
私信列表
搜索