CSS 更改 twitter bootstrap 中按钮的形状(“带箭头的”后退按钮)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9392976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 03:03:39  来源:igfitidea点击:

Change the shape of buttons ("arrow-ed" back button) in twitter bootstrap?

csstwitter-bootstrap

提问by xavier.seignard

I would like to know if there is any way to change the shape of a bootstrap button, to get something like this:

我想知道是否有任何方法可以更改引导按钮的形状,以获得如下所示的内容:

back button gmail

后退按钮 Gmail

Any tips?

有小费吗?

回答by Andres Ilich

You won't get that rounded edge on the tip of the nipple of the button unless you use an image and the :afterpseudo-element but you can come close to it by using css triangles. Here is short demo i made that uses some color trickery to come close to that effect:

除非您使用图像和:after伪元素,否则您不会在按钮的乳头尖端获得圆形边缘,但您可以通过使用 css 三角形来接近它。这是我制作的简短演示,它使用了一些颜色技巧来接近该效果:

CSS

CSS

button.btn {
    position:relative;
}

button.btn:after {
    content: " ";
    display: block;
    width: 0;
    height: 0;
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-right: 14px solid #e2e2e2;
    position: absolute;
    top: 50%;
    margin-top: -14px;
    right: 98%;
    z-index: 2;
}

button.btn:before {
    content: " ";
    display: block;
    width: 0;
    height: 0;
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-right: 14px solid #A0A0A0;
    position: absolute;
    top: 50%;
    margin-top: -14px;
    right: 97%;
    z-index: 1;
}

.btn-primary {
    background: #e2e2e2; /* Old browsers */
    background: -moz-linear-gradient(left, #e2e2e2 0%, #d1d1d1 47%, #fefefe 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,#e2e2e2), color-stop(47%,#d1d1d1), color-stop(100%,#fefefe)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* IE10+ */
    background: linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* W3C */
    text-shadow: 0 -1px 0 #fff;
    color:#777;
    border: 1px solid #A0A0A0;
}

I did not include the :hoverand :activestate styles so you can play around mixing some colors by using the Colorzillagradient generator.

我没有包含:hover:activestate 样式,因此您可以使用Colorzilla渐变生成器混合一些颜色。

Here is a demo of what the button looks like:

这是按钮外观的演示:

http://jsfiddle.net/WUn26/

http://jsfiddle.net/WUn26/