简体   繁体   English

OS X中的Safari - 与border-radius的怪异bug

[英]Safari in OS X – weird bug with border-radius

I'm experiencing some really strange problems with border radius in Safari for Mac OS X. Take a look at this jsFiddle: http://jsfiddle.net/sXxtU/1/ 我在Safari for Mac OS X中遇到了一些非常奇怪的边界半径问题。看看这个jsFiddle: http//jsfiddle.net/sXxtU/1/

Safari Mac OS X: Safari Mac OS X:
在此输入图像描述
(Top left corner, and the white vertical line) (左上角和白色垂直线)

Chrome Mac OS X: Chrome Mac OS X:
在此输入图像描述
(Perfectly fine) (非常好)

Safari iOS 6.0 Safari iOS 6.0
在此输入图像描述
(Also perfectly fine). (也很好)。

Now, in this example I am using border-radius: 5px 5px 0 0; 现在,在这个例子中我使用border-radius: 5px 5px 0 0; , ie only applying it on the top corners. ,即仅将其应用于顶角。 However, if I chose to round all the corners – I get this (in Safari for OS X): 但是,如果我选择围绕所有角落 - 我得到这个(在Safari for OS X中):

在此输入图像描述

Is this a known bug? 这是一个已知的错误? Is there some way to remedy this? 有什么方法可以解决这个问题吗? I'm guessing that it is due to some clipping issues, but no matter how I try to apply different fixes – I can't get it to look quite right. 我猜这是由于一些剪辑问题,但无论我如何尝试应用不同的修复 - 我不能让它看起来很正确。

Edit 编辑
I should point out that this is in Safari 6.0.2. 我应该指出这是在Safari 6.0.2中。 haven't got the chance to test other versions just yet. 还没有机会测试其他版本。

Edit 2 编辑2
Tried adding border: 1px solid transparent; 尝试添加border: 1px solid transparent; and it looks much better. 它看起来好多了。 However, if I go with a border color (like #fff) I still get some clipping problems (now in the top right corner...?). 但是,如果我使用边框颜色(如#fff),我仍会遇到一些剪裁问题(现在在右上角......?)。 Still very interested in learning what's going on here. 仍然非常有兴趣了解这里发生了什么。

Edit 3 编辑3
User Sparky pointed out that my HTML is invalid (having a div-element inside a ul-element) – however, I have confirmed that this have nothing to do with the issues I am having. 用户Sparky指出我的HTML无效(在ul元素中有一个div元素) - 但是,我已经确认这与我遇到的问题无关。

Edit 4 编辑4
Been testing Safari 6.0.2 some older versions of OS X, and this issue only seems to occur in 10.8.2. 一直在测试Safari 6.0.2的一些旧版本的OS X,这个问题似乎只出现在10.8.2中。 Very strange. 很奇怪。

This is happening because you are inserting a div clear inside of the unordered list. 这是因为您在无序列表中插入div清除。 Your list items should be set as display: inline-block and your ul could have a clearfix on it to maintain it's proper height even though your list items are floating left. 你的列表项应该设置为display:inline-block,你的ul可以有一个clearfix来保持它的正确高度,即使你的列表项是左浮动的。

I tested this in 6.0 and then in 6.0.2 我在6.0中然后在6.0.2中测试了这个

Here's a fork of your jsfiddle with a few tweaks. 这是你的jsfiddle的一个分支,有一些调整。

http://jsfiddle.net/rossedman425/VTySS/1/ http://jsfiddle.net/rossedman425/VTySS/1/

HTML: HTML:

<div class="container">
<div class="pill">
    <ul class="cf">
        <li><a href="#">Item 1</a></li>
        <li><a href="#">Item 1</a></li>
    </ul>
</div>

CSS: CSS:

.container {
    padding: 20px;
}
.pill {
    background-color: #00a38f;
    border-radius: 5px 5px 0 0;
}
ul {
    padding: 13px;
    list-style: none;
}
li {
    float:left;
    margin-right: 20px;
    display: inline-block;
}

.cf:before,
.cf:after {
    content: " ";
    display: table;
}
.cf:after {
    clear: both;
}
.cf {
    *zoom: 1;
}

Maybe that version of OS X is rendering the UL with some sort of background property. 也许那个版本的OS X正在为UL提供某种背景属性。 Its just a shot in the dark but maybe try background: transparent; 它只是在黑暗中拍摄但可能尝试background: transparent; on the UL . UL Or, if it will serve the same purpose, try moving the background color and border-radius to the UL . 或者,如果它将用于相同的目的,请尝试将背景颜色和border-radius移动到UL

This is in fact true and has nothing to do with the the way the code is written, it is a browser bug. 这实际上是正确的,与编写代码的方式无关,它是一个浏览器错误。

If you zoom in on a page with this bug, you will see that the rendering will display correctly for some zoom levels. 如果您放大具有此错误的页面,您将看到渲染将针对某些缩放级别正确显示。

Still found no away to fix this. 仍然找不到解决这个问题。

I cannot reproduce your problem in my version of Safari. 我无法在我的Safari版本中重现您的问题。

However, I noticed that you have invalid HTML. 但是,我注意到您的HTML无效。 As per the W3C spec , and the online HTML validator tool , <ul> elements must only contain <li> elements as immediate descendants. 根据W3C规范在线HTML验证工具<ul>元素必须仅包含<li>元素作为直接后代。

Your HTML code is invalid: 您的HTML代码无效:

<ul>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 1</a></li>
    <div class="clear"></div> <!-- this line is invalid HTML -->
</ul>

Remove <div class="clear"></div> from the <ul> and see if that clears it up... <ul>删除<div class="clear"></div> <ul> ,看看是否清除了它...

<ul>
    <li><a href="#">Item 1</a></li>
    <li><a href="#">Item 1</a></li>
</ul>

You can use overflow: on the <ul> to force it to expand to contain its children and that totally eliminates the need for a clearing div . 您可以在<ul>上使用overflow:强制它扩展以包含其子项,这完全消除了对清除div的需要。

ul {
    overflow: auto;
}

http://jsfiddle.net/sXxtU/7/ http://jsfiddle.net/sXxtU/7/

I had a similar problem, on FF20, but it appeared to only be me having accidently zoomed in on the page. 在FF20上我遇到了类似的问题,但似乎只是因为我意外地放大了页面。 Resetting the zoom to 0 removed the line. 将缩放重置为0会删除该行。

Perhaps using even numbers instead of odd numbers will work: Safari 6.0.5 on ML 也许使用偶数而不是奇数可以工作:ML上的Safari 6.0.5

In my case I tested the following: 在我的情况下,我测试了以下内容:

border-radius: 4px; /* HAPPY */
border-radius: 5px; /* SAD */
border-radius: 6px; /* HAPPY */

This appears to be a browser bug. 这似乎是一个浏览器错误。

Try the following to adjust the border radius: 请尝试以下操作来调整边框半径:

border-top-right-radius:10px;
-webkit-top-right-border-radius:10px;
border-top-left-radius:10px;
-webkit-top-left-border-radius:10px;

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

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