什么是hasLayout

IE使用Layout概念来控制元素的尺寸和位置。如果一个元素有Layout,它就有自身的尺寸和位置;如果没有,它的尺寸和位置由最近的拥有布局的祖先元素控制。

在默认情况下,拥有Layout的元素包括:

<html>, <body>
<table>, <tr>, <th>, <td>
<img>
<hr>
<input>, <button>, <select>, <textarea>, <fieldset>, <legend>
<iframe>, <embed>, <object>, <applet>
<marquee>

(注意,

默认不拥有Layout。)
凡是具有以下CSS属性的元素,也会拥有布局:
position: absolute
float: left|right
display: inline-block
width: any value other than 'auto'
height: any value other than 'auto'
zoom: any value other than 'normal' (IE专用属性)
writing-mode: tb-rl(IE专用属性)
overflow: hidden|scroll|auto(只对IE 7及以上版本有效)
overflow-x|-y: hidden|scroll|auto(只对IE 7及以上版本有效)

hasLayout是IE特有的属性,不是CSS属性。可以用Javascript函数hasLayout查看一个元素是否拥有Layout。如果有,这个函数就返回true;否则返回false。hasLayout是一个只读属性,所以无法使用Javascript进行设置。

sunbaixin wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!