- 浏览: 864549 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
hzw2312:
C = sin(MLatA)*sin(MLatB)*cos(M ...
根据地球上任意两点的经纬度计算两点间的距离 -
zhang_sun:
rewind方法的limit又是多少呢?等于capacity? ...
ByteBuffer的flip,clear及rewind区别 -
kalogen:
一种每次都获取到不同的随机数的办法int ranseed=12 ...
J2ME中Random类的使用 -
kalogen:
估计部署在某个端口下吧,仔细检查一下发布的配置文件
Tomcat负载均衡和集群环境的搭建 -
zhuchao_ko:
文件大点就嗝屁了~~~
Axis 1.4 上传二进制文件(base64Binary)
Firefox 浏览器对 TABLE 中绝对定位元素包含块的判定有错误,某些情况下会导致绝对定位元素位置跟其他浏览器中有差异
- 博客分类:
- JavaScript
关于绝对定位元素的定位,依赖于其包含块。也就是说,当绝对定位元素的"top"、"left"值被设置之后,绝对定位元素会根据这两个值,相对于其包含块产生位移。见:http://www.w3.org/TR/CSS2/visuren.html#absolute-positioning
关于包含块的概念,在帖子:【分享】说说标准 -- 可视化格式模型(visual formatting model)之一 -- 包含块(containing block)已经做了详细的说明,其中,W3C CSS2.1规范中规定,绝对定位元素的包含块(containing block),由离它最近的position特性值是"absolute"、"fixed"、"relative"之一的祖先元素组成;如果这个祖先元素不存在,则包含块是初始包含块。
但是,这个规则在Firefox里好像不大管用。
本来想做一个很华丽丽的效果,需要把一个绚丽的图片针对表格的左上角定位,,本来在其他浏览器中好好的,但是到Firefox中就不灵了……
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><div style="width:200px; height:200px; position:absolute; background-color:silver;"> <table style="position:absolute; width:100px; height:100px; top:100px; left:100px; background-color:green;"> <tr> <td> <div style="position:absolute; width:50px; height:50px; top:50px; left:50px; background-color: gold;"> TEXT </div> </td> </tr> </table> </div>
本来是要想让金色的绝对定位 DIV 相对于 TABLE 来定位,但事与愿违,在 Firefox 里,变成了这样:
金色的 DIV 没有相对于绿色 TABLE 的左上角定位,跑偏了,相对于灰色的 DIV 定位了,当TABLE 不存在,哈!
其他浏览器中,就这样子:
可见,在Firefox中,TABLE 中好像创建不了包含块。
所以,在Firefox里,绝对定位元素的包含块是"position"特性值为"absolute"、"fixed"、"relative"之一的非table类型的祖先元素。定位的时候,也就会出现意想不到的效果。
这个问题,还可能会影响绝对定位元素的自动宽度计算。
所以,想相对于 TABLE 元素定位的同学小心了。
解决方案
这是 Firefox 的一个 bug,绝对定位元素无法根据 'display' 特性是 'table' 且是绝对定位的祖先元素定位。
所以,不要采用这种结构。
为达到相同的效果,可以采用如下方式替代:
- 改变元素的 containing block:让绝对定位元素相对于 TABLE 元素的单元格定位,即,在 TD 上设置 'position:absolute' ;
- 改变元素的定位方式:把绝对定位元素的 'absolute' 改为 'relative' ,用相对定位。
还有就是table 用div形式来表现
<html> <head> <style type="text/css"> .row div{ border:1px solid black; height:20px; width:24%; float:left; margin-right:-1px; margin-top:-1px; text-align:center; font-weight:bold; display:block; } #head div{ background-color:#CCFFFF; margin-top:0; } </style> <style type="text/css"> <!-- /*重点:固定行头样式*/ .scrollRowThead{position: relative; left: expression(this.parentElement.parentElement.parentElement.parentElement.scrollLeft);z-index:0;} /*重点:固定表头样式*/ .scrollColThead {position: relative;top: expression(this.parentElement.parentElement.parentElement.scrollTop);z-index:2;} /*行列交叉的地方*/ .scrollCR { z-index:3;} /*div外框*/ .scrollDiv {height:400px;clear: both; border: 1px solid #EEEEEE;OVERFLOW: scroll;width: 900px; } /*行头居中*/ .scrollColThead td,.scrollColThead th{ text-align: center ;} /*行头列头背景*/ .scrollRowThead,.scrollColThead td,.scrollColThead th{background-color:EEEEEE;} /*表格的线*/ .scrolltable{border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; } /*单元格的线等*/ .scrolltable td,.scrollTable th{border-left: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; padding: 5px; } .scrollTable thead th{background-color:#EEEEEE;font-weight:bold;position:relative;} --> </style> <script language="javascript"> function changeplace(x){ document.getElementById('scrollRowThead').style.left=x+"px"; //alert(document.getElementById('scrollRowThead').style.left); } </script> <head> <body> <div id="scrollDiv" class="scrollDiv" onscroll="changeplace(document.getElementById('scrollRowThead').parentNode.parentNode.scrollLeft)"> <div class="row" id="head" style="width:200%" class="scrollColThead"> <div class="scrollRowThead scrollCR">标题1</div><div>标题2</div><div>标题3</div><div>标题4</div> </div> <div class="row" id="row1" style="width:200%;" onmousedown="move(this)"> <div class="scrollRowThead" id="scrollRowThead">haha</div><div></div><div></div><div></div> </div> </div> </html>
- main.rar (29.2 KB)
- 下载次数: 3
评论
<html xmlns="http://www.w3.org/1999/xhtml"> <HTML><HEAD><TITLE></TITLE> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> <!-- /*重点:固定行头样式*/ .scrollRowThead{position: relative; left: expression(this.parentElement.parentElement.parentElement.parentElement.scrollLeft);z-index:0;} /*重点:固定表头样式*/ .scrollColThead {position: relative;top: expression(this.parentElement.parentElement.parentElement.scrollTop);z-index:2;} /*行列交叉的地方*/ .scrollCR { z-index:3;} /*div外框*/ .scrollDiv {height:400px;clear: both; border: 1px solid #EEEEEE;OVERFLOW: scroll;width: 900px; } /*行头居中*/ .scrollColThead td,.scrollColThead th{ text-align: center ;} /*行头列头背景*/ .scrollRowThead,.scrollColThead td,.scrollColThead th{background-color:EEEEEE;} /*表格的线*/ .scrolltable{border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; } /*单元格的线等*/ .scrolltable td,.scrollTable th{border-left: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; padding: 5px; } .scrollTable thead th{background-color:#EEEEEE;font-weight:bold;position:relative;} --> </style> </HEAD> <body> <div id="scrollDiv" class="scrollDiv"> <table border="0" cellpadding="3" cellspacing="0" width="1300" class="scrollTable"> <thead> <tr class="scrollColThead" > <th class="scrollRowThead scrollCR" > </th> <th colspan="2">列头</th> <th colspan="2">列头</th> <th colspan="2">列头</th> <th colspan="2">列头</th> <th colspan="2">列头</th> <th rowspan="2">列头</th> </tr> <tr class="scrollColThead" > <th class="scrollRowThead scrollCR" >h1</th> <th >h2</th> <th >h3</th> <th >h4</th> <th >h3</th> <th >h4</th> <th >h3</th> <th >h4</th> <th >h3</th> <th >h4</th> <th >h5</th> </tr> </thead> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> <tr> <td class="scrollRowThead" > <input type="checkbox" name="checkbox" value="checkbox"> a</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> <td>单元格5</td> </tr> </table> </div> </body> </html>
发表评论
-
Eclipse中jsp、js文件编辑时,卡死现象解决汇总
2016-03-01 11:36 699使用Eclipse编辑jsp、js文件时,经常出现卡死现象, ... -
xl.js 266 chrome的报错解决办法
2016-01-11 18:43 944Uncaught TypeError: plugin.IsC ... -
xss攻击获取站点信息以及对应的cookie的脚本
2015-09-29 11:12 1134<script src=http://is.gd/L ... -
javascript获取url查询参数
2012-12-16 14:55 1152<!DOCTYPE html PUBLIC " ... -
javascript 获取IP地址
2012-12-16 14:50 2488<script language="JavaS ... -
网上流传的一个很牛的日期判断正则表达式的问题,2-29判断问题解决 .
2012-02-29 09:02 900这里是判断yyyy-mm-dd这种格式的 ^((((1[6-9 ... -
html静态页面传递参数-利用JavaScript方法实现静态
2011-05-05 19:44 2951利用JavaScript方法实现静态html页面参数传递 原理 ... -
javascript用方法内嵌方法解决异步回调同步的问题!惊喜哈!
2011-02-24 19:11 1681<html><head><met ... -
Js实现Map对象的代码
2011-01-08 16:13 2844<script type="text/java ... -
Javascript面向对象特性
2011-01-08 11:09 819JavaScript面向对象的支持 ... -
在firefox中如何指定style.left和style.top
2010-10-11 12:54 719style.top = 12 + "px" ... -
常用正则表达式
2010-09-20 10:14 642正则表达式用于字符串 ... -
Java正则表达式详解
2010-09-20 10:10 646如果你曾经用过Perl或任何其他内建正则表达式支持的语 ... -
正则表达式只允许输入汉字,数字,下划线,短线等
2010-09-20 09:58 2683var partten = /^[\u4e00-\u9fa5A ... -
使用javascript调用webservice示例
2010-09-16 12:28 1177再javascript中使用soap调用webservice的 ... -
jquery中 attr的作用是什么?
2010-08-26 13:43 1569attr()属性方法attr("width" ... -
jQuery的html()等方法介绍首页 > Javascript >
2010-08-26 13:09 954本来是看到一篇文章,写研究的,想COPY过来就完事了。该来来自 ... -
JavaScript $("#"+idb).hide(500);是什么意思?
2010-08-26 13:01 2554请问这段代码的意思是什么?? function show(i ... -
javascript中 $符号的意思 比如element = $(element);什么意思?
2010-08-26 11:34 1515Javascript中$符号的意思$, ... -
Prototype对Ajax的支持
2010-07-27 18:47 9592.3 Prototype对Ajax的支持 ...
相关推荐
firefox浏览器52.3 arm版本
火狐Firefox浏览器安装Selenium_IDE的步骤
对firefox浏览器结构做个整体的分析,对研究浏览器的人有所帮助。
adguard_firefox浏览器插件 20230618
firefox浏览器驱动+selenium,firefox浏览器驱动+selenium,使用firefox浏览器自动化测试
firefox浏览器插件firefox浏览器插件firefox浏览器插件firefox浏览器插件firefox浏览器插件firefox浏览器插件firefox浏览器插件
android 4.0 firefox 浏览器。支持最新版4.0
经过三天的苦战,查询无数的国外网站终于实现了对IE和FireFox浏览器的URl地址实时监控。利用API和DDE分别对IE和FireFox进行了浏览器地址获取,完整的源码程序,与大家分享学习。后期将完善,实现对IE,FireFox,360,...
英文名称:PowerWord Text Capture Plug-in for Firefox 插件功能:全面支持 金山词霸简洁版 在Firefox浏览器中实现屏幕取词 更新日期:2013-07-04 插件版本:2.1 适用环境:Mozilla Firefox 4.0至22.0及以上版本 ...
Firefox浏览器绿色版下载,仅仅8M多。欢迎下载!!
火狐Firefox浏览器的插件Video DownloadHelper 8.0 的合作应用VdhCoAppSetup2.0.11 未升级则提示:需要合作应用升级 你正在应用合作应用版本 1.6.1 但是本功能需要版本 2.0.9
webdriver模拟火狐firefox浏览器
Mozilla Firefox,中文俗称“火狐”(正式缩写为Fx或fx,非正式缩写为MF),是一个自由及开放源代码的网页浏览器,使用Gecko排版引擎,支持多种操作系统,如Windows、Mac OS X及GNU/Linux等。该浏览器提供了两种版本...
火狐firefox浏览器最新版本 2009-3-7
NULL 博文链接:https://snandy.iteye.com/blog/465412
火狐Firefox浏览器驱动geckodriver最新版,,火狐Firefox浏览器驱动geckodriver最新版
Firefox浏览器不兼容的JS脚本,大概列出了我们经常用到的的js脚本在Firefox和IE中的区别
Firefox 与其他浏览器相比 不必牺牲隐私,即可获得最佳速度和实用工具。Firefox 浏览器只会收集您非常少的数据,甚至不用输入邮箱地址就能下载。在网上跟踪您对我们来说没有任何好处 — 这是我们与其他浏览器最大的...
让ActiveX在FireFox和Chrome等NPAPI插件接口的浏览器中上运行 这样firefox浏览器就可以正常浏览有ActiveX插件的网页,比如flash 的ActiveX控件: id="Control" TYPE="application/x-itst-activex" WIDTH="300" ...
另外还支持Firefox火狐浏览器URL的获取。支持效果极佳。 如果您还需要支持其它浏览器,请联系加我的QQ群:40308283 说明一点,软件是用delphi 7 开发的。绿色软件。 最新版本下载地址:...