4
Guys I use the function (Hover) to make a DIV appear, I wonder if there is a way to make it appear when right-clicking. That is, a child DIV appears when I click on a parent DIV right-click.
Follow an example I’m trying here.
.pagina {
width: 200px;
margin-left: 119px;
}
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
list-style-type: none;
margin: 0;
padding: 0;
position: relative;
text-decoration: none;
}
#cssmenu a {
line-height: 40px;
}
#cssmenu > ul > li:hover:after {
content: '';
position: absolute;
top: 30px;
left: 0;
display: block;
width: 0;
height: 0;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #484848;
margin-left: 6px;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
width: 150px;
margin-left: -119px;
position: absolute;
z-index: 3;
}
#cssmenu .has-sub ul li a {
background: #000;
border-bottom: 1px solid #d7d7d7;
display: block;
line-height: 120%;
padding: 10px;
color: #ffffff;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
overflow: hidden;
}
#cssmenu .has-sub ul li:hover a {
background: #1E90FF;
}
<div class='pagina'>
<div id='cssmenu'>
<ul>
<li class='has-sub'><a href='#'>x</a>
<ul>
<li><a class='onclick' onclick='document.location="google.com";}'><b>link1</b></a></li>
<li><a class='onclick' onclick='document.location="google.com";}'><b>link1</b></a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class='pagina'>
<div id='cssmenu'>
<ul>
<li class='has-sub'><a href='#'>x</a>
<ul>
<li><a class='onclick' onclick='document.location="google.com";}'><b>link1</b></a></li>
<li><a class='onclick' onclick='document.location="google.com";}'><b>link1</b></a></li>
</ul>
</li>
</ul>
</div>
</div>
http://javascript.info/tutorial/mouse-events - I recommend you have a look
– João Victor Gomes Moreira
Explain better which father will be and which son will be.
– Guilherme Guini
Good in the above example I wanted the menu to embrace by right-clicking. The question of parent DIV and child DIV would be like this. I have a DIV id=father, when right-clicking on it a DIV id=son appears. Got it?
– Hugo Borges
@Hugoborges I posted an answer below, just adapt your need. Only by better understanding the question, your father are the
li
that has the a href?– Marconi
yes that’s right.
– Hugo Borges