用css怎么写弹出广告代码,JS也可以,求大神

html-css018

用css怎么写弹出广告代码,JS也可以,求大神,第1张

其实蛮简单的,你理解了他的原理就会了,简单说一下吧,首先这个广告正常显示同样不影响网页其他的内容的布局,那么他应该是突出来的对吧?这个可以用相对文档的绝对定位或者相对浏览窗口的固定定位,这个会把?

然后再说下弹出效果,这个广告本身是display:none;隐藏的,然后通过js或者jq控制当打开该网页的时候添加display:block就弹出了(显示);复杂点的,有时候弹出来之后别人把他关闭了(或者直接没有关闭按钮,那么这里直接忽略),但是你又想广告过一会又弹出来,这个怎么实现呢?

这里就用到了定时器setInterval,里面加个判断 当该广告的display是none的时候把他改为block,再设置个时间多久循环一次,比如两秒,当广告被关闭,两秒之后会判断一次,因为广告广告是关闭的(display:none)所以他会给广告更改样式(改为display:block),这样广告又出来了

怎么样这样说能够理解吧?剩下的代码就需要你来写了,只把大概思路和你说下

你这样只写样式表,看不到网面里面的html代码.是无法判断哪个样式名控制是广告内容的.

如果广告外部没有div样式标签.刚无法用样式去掉广告.必须找到这个网页面,去掉页面广告的源文件.如果广告外部有标签的话就在这个标签样式名内加入楼上说的这个样式属性{display:none}意思就是关闭这个标签的意思.

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<meta name="Copyright" content="#" />

<meta name="description" content="#" />

<meta content="#" name="keywords" />

<title>11</title>

</head>

<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<div id=duilian01 style="POSITION: absoluteTOP: 100pxHEIGHT: 300pxbackground-color: #069width: 100pxleft: 6px"></div>

<div id=duilian02 style="POSITION: absoluteTOP: 100pxHEIGHT: 300pxbackground-color: #069width: 100pxleft: 896px"></div>

<script language=JavaScript src="js/scrolljs.js" type=text/javascript></script>

<table width="778" height="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f4f4f4">

<tr>

<td></td>

</tr>

</table>

</BODY></HTML>

---------------------------------------下面是JS代码:命名scrolljs.js------------------------------------------

self.onError=null

currentX = currentY = 0

whichIt = null

lastScrollX = 0lastScrollY = 0

NS = (document.layers) ? 1 : 0

IE = (document.all) ? 1: 0

var tmp1= tmp2= tmp3 =0

tmp1 = document.body.clientHeight

var isArrayRightBanner = false

var has2ndScraper = false

if (typeof(duilian02.length) == "number") isArrayRightBanner = true

if (typeof(duilian01) == "object") has2ndScraper = true

function makewing()

{

tmp2 = document.body.clientHeight

if(tmp1 != tmp2){

tmp3 = tmp2 - tmp1

tmp1 = tmp2

if(tmp3<0){}

}

if(IE)

{

diffY = document.body.scrollTop

diffX = 0

}

else if(NS)

{

diffY = self.pageYOffset

diffX = self.pageXOffset

}

if(diffY != lastScrollY)

{

percent = .1 * (diffY - lastScrollY)

if(percent >0)

percent = Math.ceil(percent)

else

percent = Math.floor(percent)

if(IE)

{

if (isArrayRightBanner)

{

if (document.all.skyflash != null) {

document.all.skyflash.style.pixelTop += percent

}

document.all.duilian02[0].style.pixelTop += percent

document.all.duilian02[1].style.pixelTop += percent

}

else

{

if (document.all.skyflash != null) {

document.all.skyflash.style.pixelTop += percent

}

document.all.duilian02.style.pixelTop += percent

}

if (has2ndScraper) document.all.duilian01.style.pixelTop += percent

}

else if(NS)

{

if (isArrayRightBanner)

{

document.skyflash.top += percent

document.duilian02[0].top += percent

document.duilian02[1].top += percent

}

else

{

document.skyflash.top += percent

document.duilian02.top += percent

}

if (has2ndScraper) document.duilian01.top += percent

}

lastScrollY = lastScrollY + percent

}

if(diffX != lastScrollX)

{

percent = .1 * (diffX - lastScrollX)

if(percent >0)

percent = Math.ceil(percent)

else

percent = Math.floor(percent)

if(IE)

{

if (isArrayRightBanner)

{

if (document.all.skyflash != null) {

document.all.skyflash.style.pixelLeft += percent

}

document.all.duilian02[0].style.pixelLeft += percent

document.all.duilian02[1].style.pixelLeft += percent

}

else

{

if (document.all.skyflash != null) {

document.all.skyflash.style.pixelLeft += percent

}

document.all.duilian02.style.pixelLeft += percent

}

if (has2ndScraper) document.all.duilian01.style.pixelLeft += percent

}

else if(NS)

{

if (isArrayRightBanner)

{

document.skyflasy.top += percent

document.duilian02[0].top += percent

document.duilian02[1].top += percent

}

else

{

document.skyflash.top += percent

document.duilian02.top += percent

}

if (has2ndScraper) document.duilian01.top += percent

}

lastScrollY = lastScrollY + percent

}

}

if(NS || IE) action = window.setInterval("makewing()",1)

单独建一个文件夹命名js,把js文件放入文件夹内,防止路径不对出错。