-2
Galera I set up a menu that appears when placing the cursor over the letter B.
The problem is that when it is aligned to the left the menu disappears in the corner of the page.
If I remove the line (margin: 0px 0 0 -225px;) The problem is solved, however if I align the menu on the right the problem returns.
Is there any way jQuery can do this automatically?
Follow the ready menu:
.menu2 {
display: inline-block;
margin-right: -4px;
position: relative;
padding: 2px 5px;
height: 25px;
}
.link2 {
margin: 0px 0 0 -225px;
padding: 0;
position: absolute;
top: 28px;
width: 260px;
visibility: hidden;
z-index: 5;
}
.sub_menu2_inicio {
border-top: 1px solid #ffffff;
}
.sub_menu2 {
padding: 10px 8px;
cursor: pointer;
display: block;
color: #ffffff;
background: #484848;
border-left: 1px solid #ffffff;
border-right: 1px solid #ffffff;
}
.sub_menu2_fim {
border-bottom: 1px solid #ffffff;
}
.sub_menu2:hover {
background: #1E90FF;
}
.menu2:hover ul {
display: block;
visibility: visible;
left: 0;
}
.sub_menu_seta {
padding: 10px 8px;
}
.sub_menu_seta::after {
content: '';
width: 0px;
height: 0px;
display: block;
position: absolute;
margin: auto;
left: 225px;
right: 0;
top: 7px;
border-bottom: 7px solid #484848;
border-right: 7px solid rgba(0, 0, 0, 0);
border-left: 7px solid rgba(0, 0, 0, 0);
border-top: 7px solid rgba(0, 0, 0, 0);
}
<li class="menu2">
<i>B</i>
<ul class="link2">
<div class='sub_menu_seta'></div>
<li class='sub_menu2 sub_menu2_inicio'>Sobre</li>
<li class='sub_menu2 sub_menu2_fim'><b>Feedback</b></li>
</ul>
</li>
Your questions are hard to understand. Words exchanged, lack of agreement. So it is difficult to understand and help you. I suggest you explain better, review your question slowly and see if you understand it yourself. It’s a suggestion. Now, there’s a CSS property in your code that’s hiding your menu. margin: 0px 0 0 -225px; It’s this -225px.
– Diego Souza
Well sorry, I wrote the question very quickly. I will try to explain it better. If I remove the line (margin: 0px 0 0 -225px;) the menu works, the problem and that when it is aligned to the right of the screen, it will hide. What I had in mind was to make jQuery check if the menu is in the middle of hers and help the line (margin: 0px 0 0 -225px;) automatically.
– Hugo Borges
You are doing some kind of responsive menu for when the screen is smaller the menu go right?
– Bruno Romualdo
That’s right buddy, you know how I can do that?
– Hugo Borges
Already tried to use @media queries?
– Bruno Romualdo
there is no example?
– Hugo Borges
This menu is very dry, just a letter in the corner of the screen to access the menu, it will be just like that?
– Leandro RR
not that’s just an example
– Hugo Borges