jQuery 手风琴 +锚标记“卡为块”漏洞?
示例页面:
这是一个简单的 jQuery UI 手风琴。每个手风琴面板都有一个带有以下标记的 UL(OL 的工作原理相同):
<ol>
<li><a href="">Lorep ipsum dolor lorem ipsum dolor lorem ipsum dolor</a>?</li>
<li><a href="">Lorep ipsum dolor lorem ipsum dolor lorem ipsum dolor</a>?</li>
</ol>
在 IE6 中,您将看到 。标签似乎被渲染为块元素,因此问号最终被推到外面而不是文本行的末尾。此外,项目符号和/或列表项编号现在与文本底部对齐,而不是顶部对齐。
我已将其范围缩小到执行制作手风琴的 javascript。这不是 jQuery 的 CSS 的问题,因为单独禁用 CSS 并不能解决问题。
有人知道 IE6 中可能发生的情况会导致此渲染问题吗?
更新:显然,这也是 IE7 的问题。
更新 2:经过更多的游戏,我已经缩小了范围:
该错误与列表无关。问题是 jQuery Accordion 中的任何锚标记都将显示为 display: block(即使看起来 CSS 仍然指示 display: inline)
该错误与 jQuery UI 用于创建的实际 CSS 无关手风琴。我创建了一个测试页面,该页面使用完全渲染的 jQuery Accordion 后处理源代码和随附的 CSS。在这种情况下,锚标记保持内联。
结论:看来通过 JavaScript 渲染手风琴的过程弄乱了锚标记的显示。这可能是显示/隐藏问题?
Sample page:
This is a simple jQuery UI Accordion. Each accordion panel has an UL (an OL works the same) with this markup:
<ol>
<li><a href="">Lorep ipsum dolor lorem ipsum dolor lorem ipsum dolor</a>?</li>
<li><a href="">Lorep ipsum dolor lorem ipsum dolor lorem ipsum dolor</a>?</li>
</ol>
In IE6, you'll see that the <a> tag appears to be getting rendered as a block element, so the question mark ends up being pushed outside and not at the end of the line of text. In addition, the bullet and/or list item number is now bottom-aligned with the text rather than top-aligned.
I've narrowed it down to the javascript that executes to make the accordion. It's not an issue with jQuery's CSS as disabling that, alone, doesn't resolve the issue.
Anyone know what might be going on in IE6 to cause this rendering issue?
UPDATE: Apparently, this is also an IE7 issue.
UPDATE 2: After some more playing, I've narrowed things down a bit more:
the bug has nothing to do with lists. The issue is any anchor tag within a jQuery Accordion will appear as display: block (even though it appears that the CSS still indicates display: inline)
the bug has nothing to do with the actual CSS that jQuery UI uses to create the accordion. I created a test page that uses the fully rendered jQuery Accordion post-processed source code and the accompanying CSS. In that situation, the anchor tags remain inline.
In conclusion: It appears that the process of rendering the accordion via javascript is messing up the display of the anchor tags. It may be a show/hide issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案:
事实证明(毫不奇怪)这是 IE6 的 has-layout 问题。当 jQuery UI 开始构建 Accordion 时,锚标记不知何故失去了布局(或者它们被赋予了 has-layout?)。解决方案是添加一个回调函数,将其重新设置为(我认为)不具有布局:
Solution:
Turns out (no surprise) that it's a has-layout issue with IE6. When jQuery UI kicks in to build the Accordion, somehow the anchor tags lose layout (or are they given has-layout?). The solution is to add a call back function that re-sets it to (I think) NOT have has-layout: