12

This is a simple question, I even think someone asked this before, but It never got a real answer.

What I want is to avoid border overlapping, It's that simple. Here's an example:

div{
   width: 400px;
   height: 150px;
   border: 1px solid red;
   border-bottom: 7px solid black;
}

Border Overlapping

You can see that the borders overlap in the corner.

Here's the live example: jsFiddle Example

What I really want to do is to make the bottom border cover the right and left border. Can someone tell me what can I do here?

4

1 回答 1

21

你可以在你的 div 上覆盖一个伪元素:

div {
    background-color: gold;
    border-top: 4px solid #172e4e;
    height: 100px;
    position: relative;
    width: 100px;
}

div::after {
    content: "";
    position: absolute;
    bottom: 0; top: 0px; left: 0; right: 0;
    border-right:4px solid orange;
    border-left:4px solid orange;
}

示例:http: //jsfiddle.net/vpHW5/10/

于 2013-09-16T20:05:33.610 回答