主站
经典论坛
作品集
Think.Pages
博客
维基
桌面
聚合
注册
登录
帮助
客服QQ:6650171
经典论坛
«
WEB标准化专栏
« 在ie6中只能点击标题有文字的地方,为何?
‹‹ 上一主题
|
下一主题 ››
发新话题
发布投票
发布商品
发布悬赏
发布活动
发布辩论
发布视频
打印
[求助]
在ie6中只能点击标题有文字的地方,为何?
hejie06
[楼主]
高级会员
帖子
237
体力
734
威望
0
发短消息
作品 10
个人网站
1
#
大
中
小
发表于 2008-4-25 13:30
只看该作者
<!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=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> function switchMenu(evt){ var ele=evt.target||evt.srcElement; //分别针对非ie和ie,获取事件的源对象 if(ele.tagName=="H2"){ //如果是<h2> var ulu=ele.parentNode.getElementsByTagName("ul"); do{ ele=ele.nextSibling; //反复取下一个兄弟节点,直到节点为<ul>或为null }while(ele&&ele.tagName!="UL"); /* for(var i=0;i<ulu.length;i++) { if(ele==ulu[i]){continue;} ulu[i].style.display="none"; }点击栏目后是否全部收起*/ if(ele){ var display=evt.target?getComputedStyle(ele,null).display: ele.currentStyle.display; //分别针对非ie和ie,获取<ul>的当前css属性display ele.style.display=display=="none"?"":"none"; //切换 } } } </script> <style type="text/css"> *{ margin:0; padding:0; } .content{ margin:10px; } .content .sideLeft{ width:21%; float:left; margin-bottom:25px; } .content .main{ margin-left:22%; width:77%; margin-bottom:50px; } .nav{ background-color:#D9E6EF; border:1px solid #9DB0BC; padding-bottom:5px; } .nav h2{ display:block; background-color:#5998C9; margin:5px; font-size:14px; padding:5px; color:#FFFFFF; text-decoration:none; border:1px solid #fff; outline:none; cursor:pointer; background-image:url(../images/aw02.gif); background-repeat:no-repeat; background-position:97%; } .nav ul{ margin-left:0px; list-style:none; } .nav ul li{ display:block; margin:3px 5px 3px 5px; background-color:#E6F2FA; padding:3px 5px 3px 5px; color:#4A89BA; } </style> </head> <body> <div class="content"> <div class="sideLeft"> <div onclick="switchMenu(event)" class="nav"> <h2>这是第一行标题</h2> <ul> <li><a href="#" target="main">第一行子标题</a></li> <li><a href="#" target="main">第二行子标题</a></li> </ul> </div> </div> <div class="main">ddd</div> </div> </body> </html>
提示:您可以先修改部分代码再运行
如题~~
[
本帖最后由 hejie06 于 2008-4-25 13:46 编辑
]
明天会怎么样?
积分
734
阅读权限
50
性别
男
在线时间
267 小时
注册
2003-11-11
最后登录
2008-5-29
查看个人网站
查看详细资料
TOP
dansion
新手上路
帖子
20
体力
45
威望
0
当前
广东 深圳
离线
15 天
发短消息
个人网站
2
#
大
中
小
发表于 2008-4-25 14:21
只看该作者
只有A标签才能点击。
.nav ul li{
display:block;
margin:3px 5px 3px 5px;
color:#4A89BA;
}
.nav ul li a{
display:block;
width:100%;
background-color:#E6F2FA;
padding:3px 5px 3px 5px;
}
dansion
积分
45
阅读权限
10
在线时间
18 小时
注册
2007-4-27
最后登录
2008-5-14
查看个人网站
查看详细资料
TOP
hejie06
[楼主]
高级会员
帖子
237
体力
734
威望
0
发短消息
作品 10
个人网站
3
#
大
中
小
发表于 2008-4-25 14:31
只看该作者
<!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=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> function switchMenu(evt){ var ele=evt.target||evt.srcElement; //分别针对非ie和ie,获取事件的源对象 if(ele.tagName=="H2"){ //如果是<h2> var ulu=ele.parentNode.getElementsByTagName("ul"); do{ ele=ele.nextSibling; //反复取下一个兄弟节点,直到节点为<ul>或为null }while(ele&&ele.tagName!="UL"); /* for(var i=0;i<ulu.length;i++) { if(ele==ulu[i]){continue;} ulu[i].style.display="none"; }点击栏目后是否全部收起*/ if(ele){ var display=evt.target?getComputedStyle(ele,null).display: ele.currentStyle.display; //分别针对非ie和ie,获取<ul>的当前css属性display ele.style.display=display=="none"?"":"none"; //切换 } } } </script> <style type="text/css"> *{ margin:0; padding:0; } .content{ margin:10px; } .content .sideLeft{ margin-bottom:25px; } .content .main{ margin-left:22%; width:77%; margin-bottom:50px; } .nav{ background-color:#D9E6EF; border:1px solid #9DB0BC; padding-bottom:5px; } .nav h2{ display:block; background-color:#5998C9; margin:5px; font-size:14px; padding:5px; color:#FFFFFF; text-decoration:none; border:1px solid #fff; outline:none; cursor:pointer; background-image:url(../images/aw02.gif); background-repeat:no-repeat; background-position:97%; } .nav ul{ margin-left:0px; list-style:none; } .nav ul li{ display:block; margin:3px 5px 3px 5px; background-color:#E6F2FA; padding:3px 5px 3px 5px; color:#4A89BA; } </style> </head> <body> <div class="content"> <div class="sideLeft"> <div onclick="switchMenu(event)" class="nav"> <h2>这是第一行标题</h2> <ul> <li><a href="#" target="main">第一行子标题</a></li> <li><a href="#" target="main">第二行子标题</a></li> </ul> </div> </div> <div class="main">ddd</div> </div> </body> </html>
提示:您可以先修改部分代码再运行
不会的吧,我用的是onclick触发呀。我把下面的定义去掉就可以点了。
.content .sideLeft{
width:21%;
float:left;
margin-bottom:25px;
}
初步判断应该是h2内可点击的宽度出了什么问题
明天会怎么样?
积分
734
阅读权限
50
性别
男
在线时间
267 小时
注册
2003-11-11
最后登录
2008-5-29
查看个人网站
查看详细资料
TOP
dansion
新手上路
帖子
20
体力
45
威望
0
当前
广东 深圳
离线
15 天
发短消息
个人网站
4
#
大
中
小
发表于 2008-4-25 14:47
只看该作者
给事件触发标签加上背景颜色测试一下。
一般不会有问题的。
注意给标签设定高度和宽度的CSS设定
dansion
积分
45
阅读权限
10
在线时间
18 小时
注册
2007-4-27
最后登录
2008-5-14
查看个人网站
查看详细资料
TOP
hejie06
[楼主]
高级会员
帖子
237
体力
734
威望
0
发短消息
作品 10
个人网站
5
#
大
中
小
发表于 2008-4-25 14:54
只看该作者
谢谢楼上的,不过您可以没明白意思。
我的意思是点击h2这个标签,现在已经加了背景色,与背景色等肯定无关。
看了一些文章,估计是由于 layout 元素引起的,loayout浮动模型会有很多怪异的表现。
如果我给h2定义加一名zoom:1;可以解决点击问题,但是对h2外边距的定义又出问题了。
<!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=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> function switchMenu(evt){ var ele=evt.target||evt.srcElement; //分别针对非ie和ie,获取事件的源对象 if(ele.tagName=="H2"){ //如果是<h2> var ulu=ele.parentNode.getElementsByTagName("ul"); do{ ele=ele.nextSibling; //反复取下一个兄弟节点,直到节点为<ul>或为null }while(ele&&ele.tagName!="UL"); /* for(var i=0;i<ulu.length;i++) { if(ele==ulu[i]){continue;} ulu[i].style.display="none"; }点击栏目后是否全部收起*/ if(ele){ var display=evt.target?getComputedStyle(ele,null).display: ele.currentStyle.display; //分别针对非ie和ie,获取<ul>的当前css属性display ele.style.display=display=="none"?"":"none"; //切换 } } } </script> <style type="text/css"> *{ margin:0; padding:0; } .content{ margin:10px; } .content .sideLeft{ width:21%; float:left; margin-bottom:25px; } .content .main{ margin-left:22%; width:77%; margin-bottom:50px; } .nav{ background-color:#D9E6EF; border:1px solid #9DB0BC; padding-bottom:5px; } .nav h2{ display:block; background-color:#5998C9; margin:5px; font-size:14px; padding:5px; color:#FFFFFF; text-decoration:none; border:1px solid #fff; outline:none; cursor:pointer; background-image:url(../images/aw02.gif); background-repeat:no-repeat; background-position:97%; zoom:1; } .nav ul{ margin-left:0px; list-style:none; } .nav ul li{ display:block; margin:3px 5px 3px 5px; background-color:#E6F2FA; padding:3px 5px 3px 5px; color:#4A89BA; } </style> </head> <body> <div class="content"> <div class="sideLeft"> <div onclick="switchMenu(event)" class="nav"> <h2>这是第一行标题</h2> <ul> <li><a href="#" target="main">第一行子标题</a></li> <li><a href="#" target="main">第二行子标题</a></li> </ul> </div> </div> <div class="main">ddd</div> </div> </body> </html>
提示:您可以先修改部分代码再运行
而且更怪异的是,如果有多个h2,出错只对第一个h2。晕倒
<!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=gb2312" /> <title>无标题文档</title> <script type="text/javascript"> function switchMenu(evt){ var ele=evt.target||evt.srcElement; //分别针对非ie和ie,获取事件的源对象 if(ele.tagName=="H2"){ //如果是<h2> var ulu=ele.parentNode.getElementsByTagName("ul"); do{ ele=ele.nextSibling; //反复取下一个兄弟节点,直到节点为<ul>或为null }while(ele&&ele.tagName!="UL"); /* for(var i=0;i<ulu.length;i++) { if(ele==ulu[i]){continue;} ulu[i].style.display="none"; }点击栏目后是否全部收起*/ if(ele){ var display=evt.target?getComputedStyle(ele,null).display: ele.currentStyle.display; //分别针对非ie和ie,获取<ul>的当前css属性display ele.style.display=display=="none"?"":"none"; //切换 } } } </script> <style type="text/css"> *{ margin:0; padding:0; } .content{ margin:10px; } .content .sideLeft{ width:21%; float:left; margin-bottom:25px; } .content .main{ margin-left:22%; width:77%; margin-bottom:50px; } .nav{ background-color:#D9E6EF; border:1px solid #9DB0BC; padding-bottom:5px; } .nav h2{ display:block; background-color:#5998C9; margin:5px; font-size:14px; padding:5px; color:#FFFFFF; text-decoration:none; border:1px solid #fff; outline:none; cursor:pointer; background-image:url(../images/aw02.gif); background-repeat:no-repeat; background-position:97%; zoom:1; } .nav ul{ margin-left:0px; list-style:none; } .nav ul li{ display:block; margin:3px 5px 3px 5px; background-color:#E6F2FA; padding:3px 5px 3px 5px; color:#4A89BA; } </style> </head> <body> <div class="content"> <div class="sideLeft"> <div onclick="switchMenu(event)" class="nav"> <h2>这是第一行标题</h2> <ul> <li><a href="#" target="main">第一行子标题</a></li> <li><a href="#" target="main">第二行子标题</a></li> </ul> <h2>这是第二行标题</h2> <ul> <li><a href="#" target="main">第二行子标题</a></li> <li><a href="#" target="main">第二行子标题</a></li> </ul> </div> </div> <div class="main">ddd</div> </div> </body> </html>
提示:您可以先修改部分代码再运行
[
本帖最后由 hejie06 于 2008-4-25 14:59 编辑
]
明天会怎么样?
积分
734
阅读权限
50
性别
男
在线时间
267 小时
注册
2003-11-11
最后登录
2008-5-29
查看个人网站
查看详细资料
TOP
hejie06
[楼主]
高级会员
帖子
237
体力
734
威望
0
发短消息
作品 10
个人网站
6
#
大
中
小
发表于 2008-4-25 15:17
只看该作者
原因应该找到了,在On having layout一文中,英文原文在此:
http://www.satzansatz.de/cssd/onhavinglayout.htm
块级别的链接
hasLayout 会影响一个块级别链接的鼠标响应区域(可点击区域)。通常 hasLayout = false 时只有文字覆盖区域才能响应。而 hasLayout = true 则整个块状区域都可响应。添加了 onclick/onmouseover 等事件的任意块级元素也有同样的现象。
正在找处理办法,现在只想对ms说一句话,“该死的ie”~
明天会怎么样?
积分
734
阅读权限
50
性别
男
在线时间
267 小时
注册
2003-11-11
最后登录
2008-5-29
查看个人网站
查看详细资料
TOP
‹‹ 上一主题
|
下一主题 ››
版块跳转 ...
> 前台制作与脚本专栏
> 后台数据库编程
> WEB标准化专栏
> WAP 技术专栏
> 艺术与设计论坛
> Adobe Photoshop 专栏
> Fireworks 专栏
> 矢量图形专栏
> 插画手绘交流
> 用户体验综合版
> UI图形设计
> Flash 8 及之前版本
> Flash CS3 及 AS3
> Silverlight 专版
> Director 专栏
> 计算机技术
> 英语学习和技术翻译
> 摄影欣赏与技术交流
> 无线通讯与数码设备
> 企业招聘
> 体育运动、线下活动与游戏
> 创业版
最近访问的版块 ...
企业招聘
用户体验综合版
Fireworks 专栏
Flash CS3 及 AS3
UI图形设计
前台制作与脚本专栏
Flash 8 及之前版本
插画手绘交流
后台数据库编程
Adobe Photoshop 专栏
做西部数码代理.Cn1元国际45元
|
释放无穷创意-惠普A3喷墨打印机让你更精彩
加入Sun Developer Network 社区,赢推荐大奖!
Blog view