开发者

Why doesn't height() in jQuery 1.5 include height from additional line wraps?

开发者 https://www.devze.com 2023-02-10 06:44 出处:网络
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

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 mo开发者_运维知识库use's over the LI in the main nav, it sets the correct left positioning with li:hover.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号