css设置浮动广告,为什么设置的没有用

html-css06

css设置浮动广告,为什么设置的没有用,第1张

<style>

#tu{

float:right

position:fixed

right:2px

top:10px

}

</style>

<div id="tu"><img src="1.jpg" /></div>

你看这样行不!

<html><head><title>固定在底部的漂浮广告</title></head><body><script LANGUAGE='JavaScript'>var ad_float_left_src="http:/images/logo.gif"var ad_float_left_url = "http:"var ad_float_left_type = ""document.ns = navigator.appName == "Microsoft Internet Explorer"var imgheight_closevar imgleftwindow.screen.width>800 ? imgheight_close=120:imgheight_close=120window.screen.width>800 ? imgleft=15:imgleft=122function myload(){myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_closemyleft.style.left=imgleftleftmove()}function leftmove(){myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_closemyleft.style.left=imgleftsetTimeout("leftmove()",50)}function MM_reloadPage(init) {if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage}}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload()}MM_reloadPage(true)function close_float_left(){myleft.style.visibility='hidden'}if(document.ns){document.write("<div id=myleft style='position: absolutewidth:80top:300left:5visibility: visiblez-index: 1'><style>A.closefloat:link,A.refloat:visited {text-decoration:nonecolor:#000000font-size:12px}A.closefloat:active,A.refloat:hover {text-decoration:underlinecolor:#0000FFfont-size:12px}</style><table border=0 cellpadding=0 cellspacing=0><tr><td>")if(ad_float_left_type!="swf")document.write("<a href='" + ad_float_left_url + "' target = '_blank'><img src='" + ad_float_left_src + "' WIDTH=100 HEIGHT=100 border = 0></a>")elsedocument.write("<EMBED src='" + ad_float_left_src + "' FlashVars='" + ad_float_left_url + "' quality=high WIDTH=80 HEIGHT=80 TYPE='application/x-shockwave-flash' id=changhongout ></EMBED>")document.write("</td></tr><tr><td width=80 height=20 align=right><a href='javascript:close_float_left()void(0)' class=closefloat><font color=#0000ff size=2>关闭<font></a></td></tr></table></div>")myload()}</script></body></html>

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

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

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

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