jackyrong

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

<style type="text/css">
<!--
@import url("css/yangshi.css");
-->
.floatad {
        position:absolute;
        width:100px;
        height:400px;
        top:283px;
        margin-top:-200px;
        background:url(images/duilian.jpg);
}
#float1 {
        left:20px;
}
#float2 {
        right:14px;
}

</style>

</head>

<body >

<div id="float1" class="floatad"><a href="javascript:FloatDiv.Close('float1','float2');">×</a></div>
<div id="float2" class="floatad"><a href="javascript:FloatDiv.Close('float1','float2');">×</a></div>
<script>
var FloatDiv = {
        Float : function (){
                var xtop = document.documentElement.scrollTop || document.body.scrollTop;
                for(var i = 0; i < arguments.length; i ++){
                        var _float = document.getElementById(arguments[i]);
                        _float.style.top = "50%";
                        _float.style.marginTop = parseFloat(xtop) - parseFloat(_float.clientHeight) / 2 + "px";
                }
        },
        Close : function (){
                for(var i = 0; i < arguments.length; i ++){
                        var _float = document.getElementById(arguments[i]);
                        _float.style.display = "none";
                }
        }
};
window.onscroll = function () {FloatDiv.Float("float1", "float2");}
</script>

 

posted on 2010-01-28 10:15  jackyrong的世界  阅读(354)  评论(0编辑  收藏  举报