xavier.seignard
xavier.seignard

Reputation: 11154

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

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

Any tips?

Upvotes: 3

Views: 20690

Answers (1)

Andres I Perez
Andres I Perez

Reputation: 75399

You won't get that rounded edge on the tip of the nipple of the button unless you use an image and the :after pseudo-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:

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 :hover and :active state styles so you can play around mixing some colors by using the Colorzilla gradient generator.

Here is a demo of what the button looks like:

http://jsfiddle.net/WUn26/

Upvotes: 2

Related Questions