简体   繁体   English

jQuery / javascript和WebKit的浮动问题

[英]Float issue with jQuery/javascript and WebKit

I'm having a problem related to WebKit: http://demo.frojd.se/webkit/index.html 我遇到与WebKit相关的问题: http : //demo.frojd.se/webkit/index.html

When you click "Menu item 1" it shows it's children. 当您单击“菜单项1”时,将显示其为子项。 This renders fine in Firefox 3.5, IE8 and in Opera 10. In WebKit-browsers (Safari 4 and Chrome 3) it doesn't. 在Firefox 3.5,IE8和Opera 10中可以很好地呈现。在WebKit浏览器(Safari 4和Chrome 3)中却不能。

However, if I preset all the different classes and css-settings in the html, it renders correctly (without the javascript click events). 但是,如果我在html中预设了所有不同的类和css-settings,它将正确呈现(没有javascript click事件)。 I've got an URL to show you, but can't since this is my first post. 我有一个网址可向您显示,但由于这是我的第一篇文章,所以无法显示。

Any ideas on why this might be? 关于这可能是什么的任何想法?

Cheers, Robin. 干杯,罗宾。

A true and ugly hack- but hey it works. 一个真正的丑陋的骇客-但嘿,它可行。 try hiding and showing on the click of the <li> 尝试隐藏并显示<li>的点击

for a simple test: try this in console 一个简单的测试:在控制台中尝试

$('#nav li:first').hide(50).show(50)

I really haven't looked at the code closely, but something to look at in this situation is the padding or margin set on the menu item divs. 我确实没有仔细看过代码,但是在这种情况下要看的是菜单项div上设置的填充或边距。 In Safari, those are not taken into account with respect to width, so they may make the div or contents of the div expand wider than you expect, and that would cause the next element to be pushed to somewhere you don't expect it. 在Safari中,未考虑宽度方面的因素,因此它们可能会使div或div的内容扩展得超出您的预期,这将导致下一个元素被推到您不期望的位置。

Not sure if that'll help, but it's some place you can look if you're still stuck. 不确定是否会有帮助,但是如果您仍然遇到问题,可以在某个地方查看。

Edit: After looking at the source using Web Inspector, it seems the divs with class = 'parentHook' are not wide enough after getting clicked on. 编辑:使用Web Inspector查看源代码后,单击后类class ='parentHook'的div似乎不够宽。 After getting clicked on the class changes to 'parentContainer', which sets 'margin-left:-18px; 点击该类后,将其更改为“ parentContainer”,从而将其设置为“ margin-left:-18px; margin-top:-15px;', and that seems to throw off the width of that div. margin-top:-15px;',这似乎会影响该div的宽度。 In Web Inspector I changed the width of that div to 150px, and it worked as expected. 在Web Inspector中,我将该div的宽度更改为150px,并按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM