I can not speak with specific class in css

2

I made a menu and now I'm trying to style a dropdown menu, but I can not talk to a of .dropdown-content . I noticed that .header-menu ul li a is hierarchically above .dropdown-content a , but I do not figure out how to change it. Here is the code:

link

Edit: I added the code here and will try to be more specific

I'm not able to talk to a of class .dropdown-content , as you can see the styles I put in this class are not working, a is not with 60px height, text color is not white, the text is not aligned to the left ...

I have tried to assign a class to a and it did not 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>
    
asked by anonymous 22.11.2016 / 17:12

2 answers

1

With what you have presented, you can solve the problem by changing .dropdown-content to .header-menu ul li .dropdown-content , so it will give preference to the settings you want. Or you can use !important soon after setting the values of color and text-align , but using it may in the future cause problems in maintaining the site.

It would look like this:

.header-menu ul li .dropdown-content a {
  color: #fff;
  display: block;
  text-align: left;
}
    
22.11.2016 / 18:23
0
Hello, as you are referencing the elements in css makes maintenance difficult, I would recommend developing classes for the elements, I got your html and developed an example:

*{
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

.nav{
  background-color: #3498db;
  display: block;
}

.menu{
  list-style: none;
}

.menu-item, .menu-link{
  display: inline-block;
}

.menu-item:hover{
  background-color: #2980b9;
}

.menu-item:hover .sub-menu{
  display: block;
}

.menu-link{
  color: #fff;
  padding: 10px;
  position: relative;
  text-decoration: none;
}

.sub-menu{
  display: none;
  position: absolute;
  width: 200px;
}

.sub-link{
  background-color: #2980b9;
  border-top: 1px solid rgba(0,0,0,.1);
  color: #ecf0f1;
  display: block;
  padding: 10px 5px;
  text-decoration: none;
}
.sub-link:hover{
  border-left:3px solid #333;
  color: #333;
}
<nav class="nav">
  <ul class="menu">
    <li class="menu-item">
      <a href="ps4.html" class="menu-link">PS4</a>
    </li>
    <li class="menu-item">
      <a href="xboxone.html" class="menu-link">XBOX ONE</a>
    </li>
    <li class="menu-item">
      <a href="pc.html" class="menu-link">PC</a>
    </li>
    <li class="menu-item">
      <a href="outrosconsoles.html" class="menu-link">Outros Consoles</a>
      <div class="sub-menu">
        <a href="#" class="sub-link">PS3</a>
        <a href="#" class="sub-link">XBOX 360</a>
        <a href="#" class="sub-link">WII U</a>
      </div>
    </li>
  </ul>
</nav>

Notice the new classes I've added to your html and how easy it was to understand what's what.

    
22.11.2016 / 18:11