html 飘动的广告,很实用,很经典的jQuery漂浮广告

这篇博客分享了一段实用的jQuery漂浮广告代码,适用于网站站长。该代码具有良好的浏览器兼容性,可关闭功能,且能调整漂浮速度。用户可以轻松定制样式和图片。代码中详细解释了如何通过jQuery实现广告元素的动态位置调整,并提供了鼠标悬停时停止运动及点击关闭的交互功能。此外,还包括了窗口大小改变时的响应式调整。
摘要由CSDN通过智能技术生成

jQuery漂浮广告代码,很经典的浮动广告,到目前都还很实用,如果你是一位站长的话,这种代码是必备的,希望对你有用处。用jQuery兼容性好,可关闭,鼠标移动在上面时可关闭 ,可控制漂浮速度,稍微改改样式和图片就可使用。

效果演示地址:http://tangjiusheng.com/jQuery/page20180922.html

e548a8e3b631fab725615c028a97dab4.png

很经典的jQuery漂浮广告代码

jQuery漂浮广告代码

* {

margin: 0px;

padding: 0px;

}

body {

font-size: 12px;

font-family: "微软雅黑";

color: #666;

}

.conent {

width: 90px;

height: 120px;

position: absolute;

top: 20px;

z-index:99999999999999;

}

.conent .sition {

width: 90px;

height: 120px;

position: relative;

}

.conent .sition .c_adver {

width: 90px;

height: 90px;

}

.conent .sition .c_adver img {

width: 90px;

height: 90px;

}

.conent .close {

width: 16px;

height: 16px;

line-height: 14px;

font-size: 16px;

cursor: pointer;

text-align: center;

color: #000;

border: 1px solid #000;

border-radius: 100px;

position: absolute;

top: -10px;

right: -6px;

}

0ed73372ad9c6792fe450e6e4bbddbe7.png

X

$(function(){

var timer=null; //定时器

var _left=0; //默认left距离

var _top=20; //默认top距离

var top_folg=false;/*控制高度-锁*/

var left_folg=true;/*控制宽度-锁*/

//获取并计算浏览器初始宽度

var win_width=$(window).width()-$(".conent").width();

//获取并计算浏览器初始高度

var win_height=$(window).height()-$(".conent").height();

$("#liulan").html(win_height+"px");

$("#sumwid").html(win_width+"px");

action();//执行走动

$(".conent").mouseover(function(){

clearInterval(timer);

}).mouseout(function(){

action();

});

$(window).resize(function(){

conobj=$(".conent");

win_width=$(window).width()-conobj.width();

win_height=$(window).height()-conobj.height();

$("#liulan").html(win_height+"px");

$("#sumwid").html(win_width+"px");;

});

function action(){

timer=setInterval(function(){

if(!top_folg){

_top++;

if(_top>=win_height){top_folg=true;};

}else{

_top--;

if(_top<=0){top_folg=false;};

};

if(left_folg){

_left++;

if(_left>=win_width){left_folg=false;};

}else{

_left--;

if(_left<=0){left_folg=true;};

};

$("#textone").html(_top+"px");

$("#timewid").html(_left+"px");

$(".conent").animate({

left:_left,

top:_top

},1);//数字越大,速度越慢

},15);

};

//点击关闭

$(".conent .close").click(function(){

$(this).parents(".conent").slideDown(500,function(){

$(this).remove();

clearInterval(timer);

});

});

});

本文仅代表作者个人观点,不代表SEO研究协会网官方发声,对观点有疑义请先联系作者本人进行修改,若内容非法请联系平台管理员,邮箱cxb5918@163.com。更多相关资讯,请到SEO研究协会网www.seoxiehui.cn学习互联网营销技术请到巨推学院www.jutuiedu.com。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值