HTMl教程:实现网页左右两侧居中的对联广告代码

html-css015

HTMl教程:实现网页左右两侧居中的对联广告代码,第1张

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Document</title>

<style>

*{margin: 0padding: 0}

.Ad{

position: fixed

width: 140px

height: 500px

background: #db3e52

top: -moz-calc(50% - 250px)

top: -webkit-calc(50% - 250px)

top: calc(50% - 250px)

}

div.Ad:nth-child(1){

left: 2%

}

div.Ad:nth-child(2){

right:2%

}

</style>

</head>

<body>

<div class="Ad"></div>

<div class="Ad"></div>

</body>

</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script language="javascript">

<!--

var m_layer1,m_layer2

function initMove() {

m_layer1=document.getElementById("AdLayer1")

m_layer2=document.getElementById("AdLayer2")

m_layer1.style.top = "-200px"

m_layer1.style.visibility = 'visible'

m_layer2.style.top = "-200px"

m_layer2.style.visibility = 'visible'

MoveLayers()

window.onscroll=MoveLayers

}

function MoveLayers() {

var x = 5// 左右边距

var y = 100// 顶距

var st=document.documentElement.scrollTop

var cw=document.documentElement.clientWidth

var y = st + y

m_layer1.style.top = y+"px"

m_layer1.style.left = x+"px"

m_layer2.style.top = y+"px"

m_layer2.style.left = cw-m_layer2.clientWidth-x+"px"

}

window.setTimeout("initMove()",600)

//-->

</script>

<div id='AdLayer1' style='position: absolutevisibility:hiddenz-index:1'><script type="text/javascript"><!--

google_ad_client = "pub-498498484994498"

/* 160x600, 创建于 09-5-22 */

google_ad_slot = "0666243606"

google_ad_width = 160

google_ad_height = 600

//-->

</script>

<script type="text/javascript"

src="http://pagead2.googlesyndication.com/sfsfs.js">

</script></div>

<div id='AdLayer2' style='position:absolutevisibility:hiddenz-index:1'><script type="text/javascript"><!--

google_ad_client = "pub-498498484994498"

/* 160x600, 创建于 09-5-22 */

google_ad_slot = "0666243606"

google_ad_width = 160

google_ad_height = 600

//-->

</script>

<script type="text/javascript"

src="http://pagead2.googlesyndication.com/sfsfs.js">

</script></div>