Bootstrap Tutorial - Create arrow button








The following code shows how to create arrow button.

Example

<!-- Code revised from
http://fiddle.jshell.net/shpoont/3cA4x/<!--   w  w  w  .  j  a va  2  s. c o m-->
-->
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"
  href="http://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style type='text/css'>
.btn-arrow-right, .btn-arrow-left {
  position: relative;
  padding-left: 18px;
  padding-right: 18px;
}
.btn-arrow-right {
  padding-left: 36px;
}
.btn-arrow-left {
  padding-right: 36px;
}
.btn-arrow-right:before, .btn-arrow-right:after, .btn-arrow-left:before,
  .btn-arrow-left:after {
  /* make two squares (before and after), looking similar to the button */
  content: "";
  position: absolute;
  top: 5px; /* move it down because of rounded corners */
  width: 22px; /* same as height */
  height: 22px; /* button_outer_height / sqrt(2) */
  background: inherit; /* use parent background */
  border: inherit; /* use parent border */
  border-left-color: transparent; /* hide left border */
  border-bottom-color: transparent; /* hide bottom border */
  border-radius: 0px 4px 0px 0px;
  /* round arrow corner, the shorthand property doesn't accept "inherit" so it is set to 4px */
  -webkit-border-radius: 0px 4px 0px 0px;
  -moz-border-radius: 0px 4px 0px 0px;
}

.btn-arrow-right:before, .btn-arrow-right:after {
  transform: rotate(45deg);
  /* rotate right arrow squares 45 deg to point right */
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
}

.btn-arrow-left:before, .btn-arrow-left:after {
  transform: rotate(225deg);
  /* rotate left arrow squares 225 deg to point left */
  -webkit-transform: rotate(225deg);
  -moz-transform: rotate(225deg);
  -o-transform: rotate(225deg);
  -ms-transform: rotate(225deg);
}

.btn-arrow-right:before, .btn-arrow-left:before {
  /* align the "before" square to the left */
  left: -11px;
}

.btn-arrow-right:after, .btn-arrow-left:after {
  /* align the "after" square to the right */
  right: -11px;
}

.btn-arrow-right:after, .btn-arrow-left:before {
  /* bring arrow pointers to front */
  z-index: 1;
}

.btn-arrow-right:before, .btn-arrow-left:after {
  /* hide arrow tails background */
  background-color: white;
}
</style>
</head>
<body style='margin:100px'>
  <button type="button" class="btn btn-default btn-arrow-left">Default</button>
  <button type="button" class="btn btn-primary btn-arrow-left">Primary</button>
  <button type="button" class="btn btn-success btn-arrow-left">Success</button>
  <button type="button" class="btn btn-link">Link</button>
  <button type="button" class="btn btn-info btn-arrow-right">Info</button>
  <button type="button" class="btn btn-warning btn-arrow-right">Warning</button>
  <button type="button" class="btn btn-danger btn-arrow-right">Danger</button>
</body>
</html>

Click to view the demo