2
Here’s what I want.
When I hover over the li
, the div topoMenuBarra
cease to be display:none
to be display:block
, and the width
the div is equivalent to a
that exists within the li
.
He’s taking as wide as the li
.
I’ve already informed the $( ".topoMenu li a" ).hover(function()
without the a
and it doesn’t work.
$(document).ready(function(){
$( ".topoMenu li a" ).hover(function() {
var $this = $(this);
var largura = $this.width();
$( this ).find('.topoMenuBarra').css({
'display':'block',
'width': largura + 'px'
});
},
function() {
$( this ).find('.topoMenuBarra').css('display','none'); /*fazer barra desaparecer*/
});
});
.topoMenu li {
font: 300 20px/20px'Ubuntu', sans-serif;
color: #fff;
float: left;
}
.topoMenu li img {
margin-right: 95px;
margin-top: 44px
}
.topoMenu li a {
margin-top: 62px;
display: inline-block;
margin-right: 20px;
cursor: pointer;
}
.topoMenuBarra{
height: 2px;
background-color: #ced1d7;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<li>
<a href="/empresas">empresa</a>
<div class="topoMenuBarra"></div>
</li>
Exactly man, I hadn’t noticed that detail. Thank you very much.
– Felipe Viero Goulart
@Felipestoker added a variant only with CSS, I think better...
– Sergio
as I would give a margin on that edge?
– Felipe Viero Goulart
@Felipestoker will be in the
padding-bottom
. http://jsfiddle.net/hxa6zzwy/3/– Sergio
Ok, my question. If I click a little bit below, instead of being directly on top of the
a
, can be on the line itself, it will enter the link?– Felipe Viero Goulart
@Felipestoker the extra line is activated by
a:hover
so if the extra line is visible the click will open the link.– Sergio