• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

[ERLEDIGT] first-child fehler

Status
Für weitere Antworten geschlossen.

rantanplan2000

Mitglied
Hallo, also ich sitze gerade etwas ratlos da und finde den fehler nicht ... kann jemand kurz auf die sprünge helfen? irgendwie nimmt mein css selector nicht mein first-child an, sondern färbt munter und fröhlich ALLE elemente .. weder first-child noch nth-child(1) gehen?


Code:
/* Navigation */

nav {
background-color: black;
height: 60px;
}

nav ul {
margin: 0;
padding: 0;   
}

nav ul li {
list-style-type: none;
float: left;
text-align: center;
border-right: 1px dotted gray;
padding: 0 20px;
}

nav ul li a{
color: #fff;
display: block;
text-decoration: none;
padding: 0 10px;
line-height: 60px;
}

nav ul li a:hover{
color: red;
}


nav ul li a:nth-child(1){
color: red;
}
/*
nav ul li a:first-child{
color: red;
}
*/

und ne ganz normale nav im html

Code:
<nav>
<ul>
<li> <a href="#">Link 1</a> </li>
<li> <a class="activ" href="#">Link 2</a> </li>
<li> <a href="#">Link 3</a> </li>
<li> <a href="#">Link 4</a> </li>
<li> <a href="#">Link 5</a> </li>
</ul>     
</nav>
 
Werbung:
Die Selektoren werden auf das falsche Element angewendet.
CSS:
nav ul li:nth-child(1) a{
color: red;
}
oder
CSS:
nav ul li:first-child a{
color: red;
}
 
Werbung:
Status
Für weitere Antworten geschlossen.
Zurück
Oben