文法:
Object.style.position=static|relative|absolute|fixed
可能的值
<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><style type="text/css">td{width:60px;height:59px;}.staticSpan{position:static;left:40px;}.relativeSpan{position:relative;top:20px;left:20px;}.absoluteSpan{position:absolute;top:100px;left:100px;}.fixedSpan{position:fixed;top:200px;left:200px;}</style></head><body><table width="500" border="1" cellspacing="0" cellpadding="0"> <tr> <td > </td> <td><span class="staticSpan">static<span></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td height="47"> </td> <td> </td> <td><span class="relativeSpan">relative</span></td> <td> </td> <td> </td> </tr> <tr> <td height="41"> </td> <td> </td> <td><span class="absoluteSpan">absolute</span></td> <td> </td> <td> </td> </tr> <tr> <td height="35"> </td> <td> </td> <td> </td> <td><span class="fixedSpan">fixed</span></td> <td> </td> </tr></table></body></html>
效果如下:
|
static |
|
|
|
|
|
relative |
|
|
|
|
absolute |
|
|
|
|
|
fixed |
|