简体   繁体   English

显示:内联块不能用于safari

[英]Display:inline-block not working on safari

I've stucked with my friends website on a menu issue. 我在朋友网站上遇到了菜单问题。 The URL of the website is: colorfil.webd.pl/sandbox/sylwia/ 该网站的网址是:colorfil.webd.pl/sandbox/sylwia/

Please take a look on the menu (main navigation + top right menu + filers menu). 请查看菜单(主导航+右上菜单+文件管理器菜单)。 On all modern browsers: chrome, FF, opera menu looks good. 在所有现代浏览器上:chrome,FF,opera菜单看起来不错。 On Safari it sucks. 在Safari上很糟糕。 I use this simple css (for main nav): 我使用这个简单的css(用于主导航):

    #header-container li {
    display:inline-block;
    margin:0 1em;
}

Issue - menu is being extended into total page width (so the gaps between menu items are HUGE). 问题 - 菜单正在扩展到总页面宽度(因此菜单项之间的间隙是巨大的)。

Can you advice me something on that? 你能给我一些建议吗?

Debugging 调试

If something like this happens to you in the future you need to debug it. 如果将来发生类似这样的事情,你需要调试它。

All modern browsers feature in-built Web Inspectors/Developer Tools (and if they're not good enough for you - you can always grab Firebug ). 所有现代浏览器都具有内置的Web Inspectors / Developer Tools(如果它们对您不够好 - 您可以随时使用Firebug )。

If website looks different in X browsers all you need to do is to inspect the different-looking elements and then see what CSS rules are being applied to them. 如果网站在X浏览器中看起来不同,那么您需要做的就是检查看起来不同的元素,然后看看它们应用了哪些CSS规则。 The differences are almost always related to different rules being applied. 这些差异几乎总是与应用的不同规则有关。 If you can't track existing rules in your CSS files they're most likely being added with JavaScript. 如果您无法跟踪CSS文件中的现有规则,则很可能会添加JavaScript。

I've recorded a quick gif for your case, notice everything is fine after you remove floats and min-widths from your links (as previously stated by Imube). 我为你的情况记录了一个快速的GIF,注意你从链接中删除浮动和最小宽度后一切都很好 (如前面的Imube所述)。 You don't actually need floats there, as inline-block will work just fine. 你实际上并不需要浮点数,因为inline-block可以正常工作。 I'd generally recommend avoiding floats wherever possible. 我一般建议尽可能避免使用花车。

Opera vs Safari - tracking your problem using Dev Tools Opera vs Safari - 使用Dev Tools跟踪您的问题

Opera vs Safari Dev Tools

Uncompressed: https://gifyu.com/images/debug47afb.gif 未压缩: https//gifyu.com/images/debug47afb.gif

Why it was not working 为什么它不起作用

Looks like Safari interprets ignores min-width: auto in comparison other browsers (by the way what is auto supposed to mean in this case?). 看起来Safari 解释忽略了min-width: auto比较其他浏览器(顺便说一下,在这种情况下auto应该是什么意思?)。

Here's a demo that uses min-width of 150px for inline-block link and then overwrites it with auto . 这是一个演示,它使用min-width150pxinline-block链接,然后用auto覆盖它。 It works fine in other browsers, but in Safari the links are still 150px wide. 它在其他浏览器中工作正常,但在Safari中链接仍然是150px宽。

It's really easy to track down using dev tools: 使用开发工具跟踪非常容易:

Opera: 歌剧:

歌剧

Safari: 苹果浏览器:

苹果浏览器

DEMO DEMO

Learn more 学到更多

Read more about dev tools for Chrome , Firefox and in Safari . 详细了解适用于ChromeFirefoxSafari的 开发工具

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

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