尝试对CSS三角形(边框)使用自定义的十六进制颜色。但是,由于它使用边框属性,因此我不确定如何执行此操作。我仅出于兼容性考虑而避免使用javascript和css3。我正在尝试使三角形的背景为白色,且边框为1px(围绕三角形的成角边),颜色为#CAD5E0。这可能吗?这是我到目前为止的内容:

.container {
    margin-left: 15px;
    width: 200px;
    background: #FFFFFF;
    border: 1px solid #CAD5E0;
    padding: 4px;
    position: relative;
    min-height: 200px;
}

.container:after {
    content: '';
    display: block;
    position: absolute;
    top: 10px;
    left: 100%;
    width: 0;
    height: 0;
    border-color: transparent transparent transparent #CAD5E0;
    border-style: solid;
    border-width: 10px;
}​

我的小提琴:http://jsfiddle.net/4ZeCz/

最佳答案

实际上,您必须用两个三角形来伪造它。

.container {
    margin: 15px 30px;
    width: 200px;
    background: #fff;
    border: 1px solid #a00;
    position: relative;
    min-height: 200px;
    padding: 20px;
    text-align: center;
    color: #fff;
    font: bold 1.5em/180px Helvetica, sans-serif;
    text-shadow: 0 0 1px #000;
}

.container:after,
.container:before {
    content: '';
    display: block;
    position: absolute;
    left: 100%;
    width: 0;
    height: 0;
    border-style: solid;
}

.container:after {
    top: 10px;
    border-color: transparent transparent transparent #fdd;
    border-width: 10px;
}

.container:before {
    top: 9px;
    border-color: transparent transparent transparent #a00;
    border-width: 11px;
}

Updated Fiddle here

css - CSS三 Angular 形自定义边框颜色-LMLPHP

10-08 07:55
查看更多