无法使用这个简单的代码来使用css。这段代码在我的JSP页面上工作正常,但是我无法使用hovers打开:before
和:after
的颜色。
HTML
<div class="wizard">
<a class="inicio"><span></span>Anterior</a>
<a class="badge">
<span>
<h:outputText value="#{EController.form.mes} - #{EController.form.ano}" styleClass="tituloMes" style="border-bottom-style: none; border-bottom-width: 0px; height: 14px; font-size: 12pt;vertical-align:initial;"> </h:outputText>
</span>
</a>
<a class="fim"><span></span>Próximo</a>
</div>
CSS
.wizard .badge {
padding: 10px 12px 10px;
margin-right: 5px;
background: #efefef;
position: relative;
display: inline-block;
}
.wizard .badge:before {
width: 0;
height: 0;
border-top: 20 solid #FFF;
border-bottom: 20 inset #FFFFFF;
border-right: 20 solid #efefef;
position: absolute;
content:"";
top: 0;
left: 0;
}
.wizard .badge:after {
width: 0;
height: 0;
border-top: 20px inset transparent;
border-bottom: 20px inset transparent;
border-left: 20px solid #efefef;
position: absolute;
content:"";
top: 0;
right: -20px;
z-index: 2;
}
.wizard .fim {
padding: 10px 0px 5px 0px;
margin-right: 5px;
background: #007ACC;
position: relative;
display: inline-block;
width: 100px;
height: 25px;
color: white;
font-family: sans-serif;
}
.wizard .fim:before {
width: 0;
height: 0;
border-top: 20px inset transparent;
border-bottom: 20px inset transparent;
border-left: 20px solid white;
position: absolute;
content:"";
top: 0;
left: 0;
}
.wizard .fim:after {
width: 0;
height: 0;
border-top: 20px inset transparent;
border-bottom: 20px inset transparent;
border-left: 20px solid #007ACC;
position: absolute;
content:"";
top: 0;
right: -20px;
z-index: 2;
}
.wizard .inicio {
padding: 10px 12px 10px;
margin-right: 5px;
background: #007ACC;
position: relative;
display: inline-block;
width: 75px;
height: 20px;
color: white;
font-family: sans-serif;
}
.wizard .inicio:before {
width: 0;
height: 0;
border-top: 20px solid #FFF;
border-bottom: 20px inset #FFFFFF;
border-right: 20px solid #007ACC;
position: absolute;
content:"";
top: 0;
left: 0;
}
.wizard .inicio:after {
width: 0;
height: 0;
border-top: 20px solid #007ACC;
border-bottom: 20px inset #007ACC;
border-right: 20px solid transparent;
position: absolute;
content:"";
top: 0;
right: -20px;
z-index: 2;
}
.wizard .inicio:hover {
background: rgb(86, 180, 243);
color: #FFF;
}
.wizard .fim:hover {
background: rgb(86, 180, 243);
color: #FFF;
}
.wizard .fim:before:hover {
background: rgb(86, 180, 243);
color: #FFF;
}
.wizard .fim:after:hover {
background: rgb(86, 180, 243);
color: #FFF;
}
.wizard .inicio:before:hover {
width: 0;
height: 0;
border-top: 20px solid #FFF;
border-bottom: 20px inset #FFFFFF;
border-right: 20px solid #rgb(86, 180, 243);
position: absolute;
content:"";
top: 0;
left: 0;
}
.tituloMes {
font-family: Helvetica, Arial, Verdana, sans-serif;
text-align: center;
font-size: 14pt;
font-weight: bold;
color: #0073b9;
/** margin-left: 10px; **/
padding-left: 10px;
padding-right: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
height: 20px;
vertical-align:top;
}
答案 0 :(得分:0)
在:hover
元素上产生pseudo
效果时,它应该像:hover:before
一样。
在这个例子中,我做了:hover
效果。看看DEMO。
.wizard .inicio:hover{
background: rgb(86, 180, 243);
color: #FFF;
}
.wizard .inicio:hover:before{
border-top: 20px solid #FFF;
border-bottom: 20px inset #FFFFFF;
border-right: 20px solid rgb(86, 180, 243);
color: #FFF;
}
.wizard .inicio:hover:after{
border-top: 20px solid rgb(86, 180, 243);
border-bottom: 20px inset rgb(86, 180, 243);
border-right: 20px solid transparent;
color: #FFF;
}
答案 1 :(得分:0)
如前所述,您需要使用:hover:before
更改伪元素悬停状态。由于您的示例缺少悬停状态,我已经更进一步清理所有内容以获得完整的解决方案。
所有伪元素都位于其父元素之外,因此它们可以具有可用于任何背景图像或颜色的透明边框。
HTML
<div class="wizard">
<a class="inicio">test1</a>
<a class="badge">Badge can be super long</a>
<a class="fim">test2</a>
</div>
CSS
.wizard {
display:table;
margin:0 auto;
}
.wizard .badge {
background:#efefef;
position:relative;
display:inline-block;
text-align:center;
margin:0 30px;
padding:10px 12px;
}
.wizard .badge:after {
width:0;
height:0;
border-top:20px inset transparent;
border-bottom:20px inset transparent;
border-left:20px solid #efefef;
position:absolute;
content:"";
top:0;
right:-20px;
}
.wizard .badge:before {
width:0;
height:0;
border-top:20px inset transparent;
border-bottom:20px inset transparent;
border-right:20px solid #efefef;
position:absolute;
content:"";
top:0;
left:-20px;
}
.wizard .fim {
background:#007ACC;
position:relative;
display:inline-block;
width:85px;
height:25px;
color:#FFF;
font-family:sans-serif;
text-align:right;
padding:10px 0 5px;
}
.wizard .fim:after {
width:0;
height:0;
border-top:20px inset transparent;
border-bottom:20px inset transparent;
border-left:20px solid #007ACC;
position:absolute;
content:"";
top:0;
right:-20px;
}
.wizard .fim:before {
width:0;
height:0;
border-top:20px solid #007ACC;
border-bottom:20px inset #007ACC;
border-left:20px solid transparent;
position:absolute;
content:"";
top:0;
left:-20px;
}
.wizard .fim:hover:after {
border-top:20px solid transparent;
border-bottom:20px inset transparent;
border-left:20px solid #56b4f3;
}
.wizard .fim:hover:before {
border-top:20px solid #56b4f3;
border-bottom:20px inset #56b4f3;
border-left:20px solid transparent;
}
.wizard .inicio {
background:#007ACC;
position:relative;
display:inline-block;
width:65px;
height:20px;
color:#FFF;
font-family:sans-serif;
padding:10px 12px 10px 0;
}
.wizard .inicio:after {
width:0;
height:0;
border-top:20px solid #007ACC;
border-bottom:20px inset #007ACC;
border-right:20px solid transparent;
position:absolute;
content:"";
top:0;
right:-20px;
}
.wizard .inicio:before {
width:0;
height:0;
border-top:20px solid transparent;
border-bottom:20px inset transparent;
border-right:20px solid #007ACC;
position:absolute;
content:"";
top:0;
left:-20px;
}
.wizard .inicio:hover,.wizard .fim:hover {
background:#56b4f3;
color:#FFF;
}
.wizard .inicio:hover:after {
border-top:20px solid #56b4f3;
border-bottom:20px inset #56b4f3;
border-right:20px solid transparent;
}
.wizard .inicio:hover:before {
border-top:20px solid transparent;
border-bottom:20px inset transparent;
border-right:20px solid #56b4f3;
}