<title>xxxxx</title>
<meta http-equiv="content-type" content="text/htmlcharset=gb2312" />
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/javascript" src="http://w3school.com.cn/jquery/jquery.js"></script>
<style>
.tan{height:300pxbackground:url(file:///E|/%E8%A3%85%E4%BF%AE%E7%BD%91%E7%AB%99%E5%AD%A6%E4%B9%A0/tietu.jpg) no-repeat centerdisplay:none}
</style>
<script type="text/javascript">
window.onload=function(){setTimeout('dakai()',3000)} //打开页面后2秒显示出DIV
function dakai(){$(".tan").slideDown("slow")setTimeout('guanbi()',5000)}//显示出DIV后8秒关闭
function guanbi(){$(".tan").slideUp("slow")}
</script>
<style type="text/css">
#MyMoveAd {
text-align: center
height: 0px
background-color: #AC010A
background-image: url(ad.jpg)
background-repeat: no-repeat
background-position: center center
display: block
}
</style>
</script>
</body>
在一个容器里再定义一个绝对定位的p容器,再在p容器里放需要垂直居中的图片,图片定义相对定位的CSS。直接上CSS代码:#pic{width:300pxheight:300pxbackground-color:greenborder:6pxsolid#ccctext-align:centerposition:relativedisplay:.