2
I made a menu and now I’m trying to style a dropdown menu, but I’m not getting through to a
of .dropdown-content
. I realized that the .header-menu ul li a
is hierarchically above .dropdown-content a
, but I can’t figure out how to change that. Follow the code:
https://jsfiddle.net/zxvLwdjw/
Edit: I added the code here and I’ll try to be more specific
I’m having trouble talking to a
class .dropdown-content
, as you can see the styles I put in this class are not working, the a
is not with 60px
height, text color is not white, text is not left aligned...
I’ve tried assigning a class to the a
and it didn’t work.
.header-menu {
height: auto;
text-align: right;
font-size: 0;
}
.header-menu ul li {
height: auto;
display: inline-block;
}
.header img {
margin-top: 20px;
}
.header-menu ul li a {
text-align: center;
color: #000;
font-size: 14px;
line-height: 60px;
padding: 20px 12px;
text-decoration: none;
}
.header-menu ul li:hover {
background: #fd1616; /*Vermelho*/
}
/*Dropdown Menu*/
.dropdown-content {
display: none;
position: absolute;
background: #111112;
width: 130px;
padding: 10px 0;
}
.dropdown-content a {
height: 60px;
color: #fff;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background: #fd1616;
}
.dropdown:hover .dropdown-content {
display: block;
}
<nav class="header-menu">
<ul>
<li><a href="ps4.html">PS4</a></li>
<li><a href="xboxone.html">XBOX ONE</a></li>
<li><a href="pc.html">PC</a></li>
<li class="dropdown">
<a href="outrosconsoles.html">Outros Consoles</a>
<div class="dropdown-content">
<a href="#">PS3</a>
<a href="#">XBOX 360</a>
<a href="#">WII U</a>
</div>
</li>
<li><a href="esports.html">eSports</a></li>
<li><a href="reviews.html">Reviews</a></li>
<li><a href="videos.html">Vídeos</a></li>
</ul>
</nav>
Put the relevant portion of the code into the question. You can keep the link as an add-on, of course, but the questions can’t depend on external content (and it’s not even cool for people to have to look for things outside the site to help). Take the [Edit] to better explain what is the result you need, and not only how you are trying to solve.
– Bacco
Because you do not assign a class to <a tags> ?
– leofontes
I edited with code and more information. I’ve tried assigning a class to <a> and it didn’t work
– Gabriel Souza
@Gabrielsouza has improved a lot, but which of the The you speak?
– Bacco
@Gabrielsouza is with 60 px yes, only with padding. Put a padding:0 that is to solve. These things you see easy using the browser inspector.
– Bacco
@Gabrielsouza I believe that if you change the CSS of
.dropdown-content a
for.header-menu ul li .dropdown-content a
you can use the properties. Or you can use!important
in thecolor
and in thetext-align
, although in the future I may bring you trouble– Willian
Have you ever heard of bootstrap?
– Kenny Rafael
The way you’re going, there’s only one person left to recommend jQuery now.
– Bacco
Have you ever used jQuery ?
– Diego Souza
Have you heard the word of our savior Angularjs?
– Jéf Bueno
@Gumball now no longer missing kkkk
– Bacco
Thanks William! Just putting the class . header-menu ul li in front already solved
– Gabriel Souza
@Willian posts as an answer, so Gabriel can mark as accepted and close the matter
– Bacco
@Gabrielsouza If you can mark the answer as accepted, I thank you
– Willian