如何制作跟随画面走的图片

来源:百度知道 编辑:UC知道 时间:2024/05/22 22:18:43
看到很多网页里有些广告图片可以跟随浏览窗口一起走 比如向下拉滚动条,那个图片也会随画面向下移.
请问大虾们 这代码是什么? 该怎么做?
我试了 第一个能显示 但是不随画面走

这个可以
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<script type="text/javascript">
//<![CDATA[
var tips; var theTop = 250; var old = theTop;
function initFloatTips() {
tips = document.getElementById('shaoqian');
moveTips();
};
function moveTips() {
var tt=50;
if (window.innerHeight) {
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}
else if (document.body) {
pos = document.body.scrollTop;
}
pos=pos-tips.offsetTop+theTop;
pos=tips.offsetTop+pos/10;
if (pos < theTop) pos = theTop;
if (pos != old) {
tips.style.top = pos+"