为什么 jQuery 1.5 中的 height() 不包含额外换行的高度?
我使用 jQuery 来显示将鼠标悬停在主导航链接上时出现的子导航菜单。这在 Chrome、Safari、Firefox 中运行良好,但在 IE 6 和 IE 6 中运行良好。 7. 它不包括子导航菜单上的额外高度,这些菜单的文本换行超过一行。
例如,一个菜单具有三个子导航链接。其中一个链接太长,因此换行为两行。当我将高度放入alert() 中时,它仅显示包含 UL 的 78 像素高,而 Firefox 和 webkit 浏览器显示的高度为 92 像素。
有谁知道如何让 IE 从占用多行的链接中获取所需的额外高度?
以下是我获取高度的方法:
var $subnav = $(this).find("ul.subnav"),
subnavHeight = $subnav.height();
在CSS中,我使用position:absolute和left -9999px,然后当用户鼠标悬停在主导航中的LI上时,它会使用li:hover设置正确的左侧定位。
I'm using jQuery to display sub nav menus that appear when hovering over the main nav link. This works fine in Chrome, Safari, Firefox, but in IE 6 & 7 it doesn't include the extra height on sub nav menus that have text that wraps more than one line.
For example, one menu has three sub-nav links. One of the links is too long so it wraps to two lines. When I put the height in an alert() it's only showing 78 pixels high for the containing UL, where as Firefox and webkit browsers are showing the height is 92 pixels.
Does anyone have an idea how to get the IEs to pick up the additional height needed from the links that take up more than one line?
Here's how I'm getting the height:
var $subnav = $(this).find("ul.subnav"),
subnavHeight = $subnav.height();
In the CSS I'm using position: absolute with left -9999px then when the user mouse's over the LI in the main nav, it sets the correct left positioning with li:hover.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你们有 IE 的开发者工具栏吗?用它检查ul的实际高度。请记住,当您在元素上设置position:absolute时,它会脱离页面的正常流程,并且其容器高度不受其自身高度的影响。
拥有一些 html/css 可能会有所帮助。
Do you have the developer toolbar for IE ? Check the actual height of the ul with it. Remember that when you set position:absolute on an element, it goes out of the normal flow of the page, and its container height isnt affected by its own height.
It might be helpful to have some of the html/css maybe.