Skip to content

Instantly share code, notes, and snippets.

@bjcull
Last active March 5, 2017 22:30
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bjcull/9498339 to your computer and use it in GitHub Desktop.
Save bjcull/9498339 to your computer and use it in GitHub Desktop.
Wizard style navigation tabs for bootstrap
.nav-pills.nav-wizard > li {
position: relative;
overflow: visible;
border-right: 15px solid transparent;
border-left: 15px solid transparent;
}
.nav-pills.nav-wizard > li + li {
margin-left: 0;
}
.nav-pills.nav-wizard > li:first-child {
border-left: 0;
}
.nav-pills.nav-wizard > li:first-child a {
border-radius: 5px 0 0 5px;
}
.nav-pills.nav-wizard > li:last-child {
border-right: 0;
}
.nav-pills.nav-wizard > li:last-child a {
border-radius: 0 5px 5px 0;
}
.nav-pills.nav-wizard > li a {
border-radius: 0;
background-color: #eee;
}
.nav-pills.nav-wizard > li:not(:last-child) a:after {
position: absolute;
content: "";
top: 0px;
right: -20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: transparent transparent transparent #eee;
z-index: 150;
}
.nav-pills.nav-wizard > li:not(:first-child) a:before {
position: absolute;
content: "";
top: 0px;
left: -20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: #eee #eee #eee transparent;
z-index: 150;
}
.nav-pills.nav-wizard > li:hover:not(:last-child) a:after {
border-color: transparent transparent transparent #aaa;
}
.nav-pills.nav-wizard > li:hover:not(:first-child) a:before {
border-color: #aaa #aaa #aaa transparent;
}
.nav-pills.nav-wizard > li:hover a {
background-color: #aaa;
color: #fff;
}
.nav-pills.nav-wizard > li.active:not(:last-child) a:after {
border-color: transparent transparent transparent #428bca;
}
.nav-pills.nav-wizard > li.active:not(:first-child) a:before {
border-color: #428bca #428bca #428bca transparent;
}
.nav-pills.nav-wizard > li.active a {
background-color: #428bca;
}
.nav-pills {
&.nav-wizard {
> li {
position: relative;
overflow: visible;
border-right: 15px solid transparent;
border-left: 15px solid transparent;
+ li {
margin-left: 0;
}
&:first-child {
border-left: 0;
a {
border-radius:5px 0 0 5px;
}
}
&:last-child {
border-right: 0;
a {
border-radius:0 5px 5px 0;
}
}
a {
border-radius: 0;
background-color: #eee;
}
&:not(:last-child) a:after {
position: absolute;
content: "";
top: 0px;
right: -20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: transparent transparent transparent #eee;
z-index: 150;
}
&:not(:first-child) a:before {
position: absolute;
content: "";
top: 0px;
left: -20px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: #eee #eee #eee transparent;
z-index: 150;
}
&:hover {
&:not(:last-child) a:after {
border-color: transparent transparent transparent #aaa;
}
&:not(:first-child) a:before {
border-color: #aaa #aaa #aaa transparent;
}
a {
background-color: #aaa;
color: #fff;
}
}
&.active {
&:not(:last-child) a:after {
border-color: transparent transparent transparent #428bca;
}
&:not(:first-child) a:before {
border-color: #428bca #428bca #428bca transparent;
}
a {
background-color: #428bca;
}
}
}
}
}
@jitendravyas
Copy link

any change need to be done in HTML?

@sajidali
Copy link

@clockwiseq
Copy link

This looks nice, but what purpose would it serve since most navigation-style designs have the intent to submit a form upon navigating to/from a step?

@stnor
Copy link

stnor commented Jan 26, 2016

Need to add the following to make it safe on non-white backgrounds.

.nav-pills {
  &.nav-wizard {
    >li+li {
      margin-left: 0;
    }

@bjcull
Copy link
Author

bjcull commented Jan 27, 2016

Thanks for that @stnor, gist has been updated :)

@alfiyan28
Copy link

if I have 4 navs

A -> B -> C -> D

how to:

  1. if user at A. nav B, C and D was disabled
  2. if user at A, user can't acces C or D without through B
  3. when user already at B (and already fill questionnaire at A (connect with database)), nav A change color to green

thanks for your answerd

@tiesont
Copy link

tiesont commented Mar 5, 2017

Just an FYI, this is more or less broken when using Bootstrap 4 - the nav pill structure has been slightly updated. Here's a BS4-compatible CSS version: https://gist.github.com/tiesont/5b291c8344944f22c3d67cb902464048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment