html - CSS 自定义形状按钮有两种颜色

标签 html css css-shapes

我正在努力使用 CSS 创建这个“按钮”。 我还希望能够在 HTML 中手动添加文本“ABI”和“12/19”,以便我可以更改它。

附上我想要的尺寸结果。

CSS button

感谢您的帮助。

最佳答案

我很高兴创建它,它并不完美,您需要一些调整才能使其与图像完全一样,但它应该让您走上正确的道路:

<强> FIDDLE DEMO

html:

<div id="abi">ABI</div>
<div id="number">12/19</div>

CSS

div{
    float:left;
    height:60px;
    line-height:60px;
    font-size:20px;
    margin:0;
    padding:0;
}
#abi{
    width:75px;
    background:gray;
    color:blue;
    padding-left:25px;
    position:relative;
    z-index:2;
    -webkit-border-radius: 5px 0 0 5px;
border-radius: 5px 0 0 5px;
}
#abi:after{
    content:"";
    position:absolute;
    right:-10px;
    top: 19px;
    width: 0; 
    height: 0; 
    border-top: 11px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 10px solid gray;
}
#number{
    width:155px;
    text-align:right;
    padding-right:25px;
    background:blue;
    color:gray;
    -webkit-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;

}

关于html - CSS 自定义形状按钮有两种颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20951767/

相关文章:

javascript - 如果有多个div具有相同的函数,如何使用函数调用div的属性值?

html - 使用 bootstrap 我该怎么做?

html - 如何使用 CSS 创建自定义三 Angular 形

css - 在右边界画三 Angular 形

html - 如何使用 CSS 创建带边框的透明三 Angular 形?

javascript - pdf.js 和 viewer.html 默认缩放初始值

html - 在 html 中显示 flex 及其所有兼容性。类与 Id 和标签

html - 在 child 悬停时,为容器添加背景颜色

jquery - 向div中的第二个 child 添加属性

html - jqgrid fluid 最后一列适合