css实现网页布局随滚轮变化响应移动_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:23:22
Original
1438 people have browsed it

_position:absolute; _top:expression(eval(document.documentElement.scrollTop));

1、第一句代码

_position:absolute;
Copy after login

这句代码的意思是“位置:绝对定位”,也就是说元素的位置是相对于整个浏览器窗口的,而不是相对于父元素。一般要配合top、left属性使用。

2、第二句代码

_top:expression(eval(document.documentElement.scrollTop));
Copy after login

top属性是定义元素的顶部在网页中的位置,而CSS中的expression属性是用来调用Javascript代码。所以expression后面的括号中就是一行Javascript代码。

eval(document.documentElement.scrollTop);
Copy after login

 

其中,document.documentElement.scrollTop 的意思是获取当前页面滚动条所滚动到的位置的数值,而再用eval()函数把它计算成数值。

所以这句代码最终的意思就是:你浏览器窗口的滚动条滑到哪,这个元素的位置就在哪。

3、前面的下划线是CSS Hack中的用法,用来区分不同的浏览器以解决兼容问题,此处的下划线只有IE6能识别,而IE7、IE8、Firefox等浏览器是识别不了的,所以这两行代码只对IE6有效,其他浏览器是忽略它们的。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!