如何在CSS中创建三重div边框

时间:2013-07-27 23:28:48

标签: css css3 border

我想创建以下div边框: enter image description here 我将绿色边框部分排序,但不是顶部的红线。有什么想法吗?

到目前为止

代码:

#myborder {
border: 4px solid green;
}

2 个答案:

答案 0 :(得分:4)

使用此css http://jsfiddle.net/PESHk/3

#myborder {
    box-shadow: 0 0 0 4px  green, 0 0 0 4px  green inset;
    border-top:2px solid red;
    padding:8px;
}

答案 1 :(得分:2)

致力于Hushme的回答:http://jsfiddle.net/PESHk/2/

#myborder {
    box-shadow: 0 0 0 4px  green, 0 0 0 4px  green inset;
    border-top: 2px solid red;
    padding: 8px;
}

here使用::before

#myborder {
    box-shadow: 0px 4px 15px rgba(0,0,0,0.15);
    border: 8px solid green;
    border-top: 0;
    padding: 16px 8px 8px 8px;
    position: relative;
}

#myborder::before {
    width: 100%;
    background: red;
    height: 2px;
    border: 4px solid green;
    content: "";
    display: block;
    position: absolute;
    left: 0;
    top: 0;  
}