Semantically, the information I want to display is a series of user selectable stages of a pipeline.
Example:
[Stage1 (4 items) |> Stage2 (10 items) |> Stage3 (4 items)]
I am using bootstrap 3 and jQuery.
Here is the css I attempted to put a triangle on the right of a button.
.btn:not(:last-child)::after {
z-index:2;
position: relative;
left: 19px;
display: inline-block;
/* Triange like this > */
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid grey;
content: '';
}
http://codepen.io/smartnut007/pen/LpLVje
The codepen has both a sample of my desired outcome and also my very unsuccessful attempt at it. I sort of figured how to make the arrow display using CSS. But, am stuck with the rest of it.
Couple of nube questions, if you will indulge me 🙂
A) The arrow works on a simple button. But, the positioning of the arrow is off once I put richer html in the button. What is a smarter way to position this ?
B) As a next step, I want the active stage to be highlighted (.btn-primary or some such thing to mark it active). How can I make both the arrow and the selected section/button highlight to the same color ?
C) Is a button and button group the right way to go about it ? I am also open to others such as horizontal list group etc if it will be easier.
Whatever technique, I would prefer it to work for at least IE9+ and other major browsers.
Update:
I was able achieve most of what I wanted here http://jsfiddle.net/rqu7vrnh/2/
4
Answers
You are on the right track. Just a couple of fixes is what you need.
Your buttons should be
position
edrelative
and the arrows asabsolute
. This will help you precisely position the arrows where you want.Use the
:hover
on your buttons to change theborder-left
color. Also, on the.active
of your buttons, because Bootstrap way of highlighting the active button is to add theactive
class. You could also do that for:active
and:focus
while you are at it.Example Fiddle: http://jsfiddle.net/abhitalks/onxrj3wt/1/
Example Snippet:
Note: The above example is a quick demo. Specificity of the elements is not considered. In your production code, you should carefully look at the specificity of the rules which override Bootstrap ones, so that
!important
is avoided.Change your CSS to below snipet. Using btn-primary class will activate the button.
This may help or give you some ideas.
You need to understand the structure first. As per image in codepen, it shows that you want dives in row having borders with different gauge. You need to understand the placing of border as per image.
Anyways I tried answering your question But checkout Abhitalks answer and understand the things.
CodePen: http://codepen.io/anon/pen/LpLpxM
Try out below,