1
I have a div
which will contain in your Hover a specific color, this color will depend on the a
that exists above it.
.homeNoticiasOpacidade {
width: 100%;
height: 100%;
background-image: url("../imagens/engenhariaPNG.png");
top: 0;
position: absolute;
z-index: 2;
background-repeat: repeat;
right: 0;
display: none;
}
.homeNoticias li:hover .homeNoticiasOpacidade {
display: block;
}
.homeNoticiasOpacidadeEngenharia {
background-image: url("../imagens/engenhariaPNG.png");
}
.homeNoticiasOpacidadeHospitalar {
background-image: url("../imagens/hospitalarPNG.png");
}
.homeNoticiasOpacidadeElevadores {
background-image: url("../imagens/elevadoresPNG.png");
}
.homeNoticiasOpacidadeIluminacao {
background-image: url("../imagens/IluminacaoPNG.png");
}
<ul class="homeNoticias margin-top-40">
<li>
<div class="p-relative">
<a href="/engenharia">
<div class="homeNoticiasOpacidade homeNoticiasOpacidadeEngenharia"></div>
<img src="./imagens/noticias1.jpg" height="305" width="250" alt="" title="" />
<div class="homeNoticiasFundo">
<span class="homeNoticiasData">03/09/2014</span>
<span class="homeNoticiasDescricao">Lorem ipsum dolor sit amet, meis omnes ei cum, solet.</span>
<div class="clear"></div>
<a href="#" class="flechaPreta flechaBranca p-absolute bottom-20"></a>
</div>
</a>
</div>
</li>
<li>
<div class="p-relative">
<a href="/hospitalar">
<div class="homeNoticiasOpacidade homeNoticiasOpacidadeEngenharia"></div>
<img src="./imagens/noticias1.jpg" height="305" width="250" alt="" title="" />
<div class="homeNoticiasFundo">
<span class="homeNoticiasData">03/09/2014</span>
<span class="homeNoticiasDescricao">Lorem ipsum dolor sit amet, meis omnes ei cum, solet.</span>
<div class="clear"></div>
<a href="#" class="flechaPreta flechaBranca p-absolute bottom-20"></a>
</div>
</a>
</div>
</li>
</ul>
What do I want to do?
When the user hovers the mouse over the li
who has the a
/engineering he adds the class homeNoticiasOpacidadeEngenharia
to class homeNoticiasOpacidade
. Or, if you have the /hospital it includes the class homeNoticiasOpacidadeHospitalar
How could I do that?
The (window.location.toString().indexOf('/engenharia') > 0)
functionary?
You want to "mount" the class name according to the link, is that it? (e.g., if you have
/engenharia
flippedhomeNoticiasOpacidadeEngenharia
, if you have/hospitalar
flippedhomeNoticiasOpacidadeHospitalar
etc.)– mgibsonbr
That’s right @mgibsonbr
– Felipe Viero Goulart