简体   繁体   English

CSS左右边框不正确显示

[英]CSS border-left/right not displaying properly

*EDIT *编辑

I jumped the gun a little bit, its the border-bottom that causes it. 我把枪稍微跳了一下,造成了它的边界底部。

New question: 新问题:

Can you remove the picture frame effect from borders? 可以消除边框的相框效果吗?
在此处输入图片说明


So i have this CSS code on a div: 所以我在div上有以下CSS代码:

border-left: 5px solid #009933;

It displays fine in Safari: 在Safari中显示正常:
在此处输入图片说明

But it displays like this in Firefox and Chrome: 但是在Firefox和Chrome中显示如下:
在此处输入图片说明

So i guess my question is, why does Firefox and Chrome display it differently and how can i make it look like Safari displays it? 所以我想我的问题是,为什么Firefox和Chrome会以不同的方式显示它,以及如何使其看起来像Safari一样?

Thanks 谢谢

The exact rendering of border corners differ between browsers. 不同浏览器的边框角的确切呈现方式有所不同。

With thick borders, the browser tries to make a diagonal boundary between the borders. 使用粗边框,浏览器会尝试在边框之间建立对角线边界。 The pixels right in the corner can get the color from one of the borders: 角落中的像素可以从边框之一获得颜色:

******************
+*****************
++****************
+++***************
++++
++++
++++

or the other border: 或其他边界:

+*****************
++****************
+++***************
++++**************
++++
++++
++++

Different browsers will use either of those two approaches, but differently on all four corners of the element. 不同的浏览器将使用这两种方法中的任一种,但是在元素的所有四个角上将使用不同的方法。 I once compared what different browsers use, and it almost seemed like each browser vendor went out of their way to pick an approach that no other browser used. 我曾经比较过不同浏览器的使用方式,似乎每个浏览器供应商似乎都选择了其他浏览器都没有使用的方法。

In your case Firefox and Chrome happen to use the horizontal border color for the boundary on the bottom left corner. 在您的情况下,Firefox和Chrome恰好使用水平边框颜色作为左下角的边界。

To get the side borders to go on the outside, ie: 要使侧面边框在外部延伸,即:

++++******************
++++******************
++++******************
++++******************
++++
++++
++++
++++

you would use one element inside another, and set the vertical borders on the outer element and the horizontal borders on the inner element. 您可以在另一个元素内部使用一个元素,并在外部元素上设置垂直边框,在内部元素上设置水平边框。

Example (with exaggerated border widths just to show the effect): 示例(带有夸张的边框宽度只是为了显示效果):

 .outer { border: 10px #0c0; border-style: none solid; } .inner { border: 10px #ccc; border-style: solid none; } 
 <div class="outer"><div class="inner">Demo</div></div> 

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

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