我正在尝试在CSS中创建进度条,而在样式某些组件方面遇到了麻烦。悬停时,似乎无法使箭头更改框的颜色。
这是按钮之一的html
<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>
这是箭头的CSS
.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/
这是达到这种效果的合理方法,还是我应该做一些完全不同的事情?
编辑:
我按照建议去做,并且在上课之前和之后使用。
http://jsfiddle.net/waspinator/tqVjX/
现在如何在不替换文本的情况下将圆圈定位在中间?
编辑2:
好的另一种方法,但是现在我得到的文本不能超过一行
http://jsfiddle.net/waspinator/fwN7P/8/
最佳答案
这是一种达到预期效果的方法:
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;
}