首先欢迎您进入这个帖子
其次 问题是    我是这么写的  大家注意那段红色的部分我注释掉就可以正常运行  不注释掉  死活不是我想要的效果  可是注释掉了我的样式啊  就乱七八糟  特请教高人
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <style>
<!--
.div{
 position: absolute;
 border: 2px solid red;
 background-color: #EFEFEF;
 line-height:90px;
 font-size:12px;
 z-index:1000;
}
-->
</style>
<script type="text/javascript">
function scall(){
  document.getElementById("Div").style.top=document.body.scrollTop; alert(document.getElementById("Div").style.top);
 document.getElementById("Div").style.left=document.body.scrollLeft;}window.onscroll=scall;
</script></head>
<body >
    <form id="form1" runat="server">
    <div>
    <div id="Div" class="div" style="width:240px; height:90px;" align="center"><a href="http://www.baidu.com"><img src=1.gif /></a></div>
<div style="position: absolute; top: 0; left: 0; width:100px; height:1000px;"></div>
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    <!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    </head>
    <body>
    <div style="width:100px;height:100px;position:absolute;right:20px;top:80px;background:#FFCC00;border:1px solid #999;"></div>
    <script type="text/javascript">
    <!--
     var i=0, str="";while(i++<100){str+="<br>"}
     document.write(str);
     var div = document.getElementsByTagName("div")[0];
     var y = parseInt(div.style.top);
     setInterval(function(){
      var cy = parseInt(div.style.top);
      var dy = document.body.scrollTop || document.documentElement.scrollTop;
      div.style.top = (cy + (dy -(cy-y))*0.1) + "px";
     },10);
    //-->
    </script>
    </body>
    </html>
      

  2.   

    这说明你写的css样式不符合W3C规则,你应该再改下你的样式