Reputation: 6816
I'm trying to make a progress bar in CSS, and I'm having trouble styling some of the components. I can't seem to get arrows to change color with the box when hovering.
this is the html for one of the buttons
<li>
<div class="arrow-in"></div>
<div class="outerContainer done">
<div class="innerContainer">
<div class="element"><a href="#">Step 2</a></div>
</div>
</div>
<div class="arrow-right"></div>
</li>
and this is the css for the arrows
.arrow-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 20px solid #EBEBEB;
display: inline-block;
float: left;
}
.arrow-in {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 20px solid #FFF;
display: inline-block;
float: left;
background-color: #EBEBEB;
}
http://jsfiddle.net/waspinator/sxC8e/
Is this a reasonable approach for this effect or should I be doing something completely different?
EDIT:
I did as suggested and used before and after classes.
http://jsfiddle.net/waspinator/tqVjX/
how could I now position the circles to be in the center right without displacing text?
EDIT2:
ok another method, but now I can't get more than one line of text
http://jsfiddle.net/waspinator/fwN7P/8/
Upvotes: 0
Views: 2893
Reputation: 6816
here is a way to achieve the desired effect:
http://jsfiddle.net/waspinator/fwN7P/11/
html
<button>
<a href="">one line</a>
<i></i>
</button>
<button id="current">
<a href="">two lines of text</a>
<i></i>
</button>
<button>
<a href="">three lines of text in this one </a>
<i></i>
</button>
<button>
<a href="">the most extreme case with four lines of text</a>
<i></i>
</button>
css
a{
text-decoration: none;
color: black;
}
button {
background:#ddd;
border:0;
font-weight:bold;
cursor:pointer;
position:relative;
padding:0px 50px 0px 15px;
width: 150px;
height: 60px;
font-size: 0.7em;
vertical-align: top;
}
button:hover{
background: gray;
}
button:hover:before{
border-top:30px gray solid;
border-bottom:30px gray solid;
}
button:hover:after{
border-left:15px gray solid;
}
#current {
background: red;
}
#current:before
{
border-top:30px red solid;
border-bottom:30px red solid;
}
#current:after
{
border-left: 15px solid red;
}
#current .element a {
color: #FFFFFF;
}
button:before {
content:'';
border-top:30px #ddd solid;
border-bottom:30px #ddd solid;
border-left:15px #fff solid;
position:absolute;
top:0;
left:0;
}
button:after {
content:'';
border-top:30px #fff solid;
border-bottom:30px #fff solid;
border-left:15px #ddd solid;
position:absolute;
top:0;
right:0;
}
button i:after {
content:'\2713';
width:25px;
color: white;
height:25px;
font-size: 20px;
background: green;
border-radius: 25px;
line-height: 25px;
position:absolute;
top:0;
bottom:0;
margin:auto;
right:20px;
}
Upvotes: 1