开发者

Safari returning wrong CSS value in jQuery

I'm trying to replace a <select> element with a <div> that perfectly matches it using jQuery. Unfortunately browsers all argue on the actual width/height of the object, so I have it so you need to manually开发者_如何学C enter a height. However, I want it so that the height you enter includes the padding height, so when setting the height of the div - I used this code

$(divObject).height(options.height - $(this)
  .css("padding-top")
    .replace("px", "") - $(this)
      .css("padding-bottom")
        .replace("px", ""))

Where $(this) is the <select> element.

This works fine in all browsers... Except Safari. Safari has somehow decided that even if I explicitly set padding-top and padding-bottom to, say, 5px - that the actual values are 2px.

Being cross-browser compliant on this is really taking me to my wit's end here. Any help would be much appreciated :(


Probably you should use jQuery.outerHeight?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜