Avatar billede jes9 Nybegynder
29. oktober 2002 - 12:10 Der er 12 kommentarer og
1 løsning

2 "Style" på en side?

Hvad er der galt med denne kode?
"Style" virker ikke!

<html>

<head>

<STYLE>
Body {
a:link        { color: 000000; text-decoration: none; }
a:active      { color: 000000; text-decoration: none; }
a:visited    { color: 000000; text-decoration: none; }
a:hover      { color: cccccc; text-decoration: none; }
}
.menu1 {
a:link        { color: ffffff; text-decoration: none; }
a:active      { color: ffffff; text-decoration: none; }
a:visited    { color: ffffff; text-decoration: none; }
a:hover      { color: cccccc; text-decoration: none; }
}
</style>


</head>


<body bgcolor="#dddddd">

<tr>
<td> <a href="http://www.dr.dk">Sort</a> </td>
</tr>

<tr>
<td class="menu1"><a href="http://www.dr.dk">Hvid</a>  </td>
</tr>

</body>

</html>
Avatar billede Slettet bruger
29. oktober 2002 - 12:12 #1
<a href="http://www.dr.dk" class="menu1">
Avatar billede pelkjaer Nybegynder
29. oktober 2002 - 12:13 #2
Du overlapper

body { background-color:#cccccc; }
a  { color: 000000; text-decoration: none; }
a:active  { color: 000000; text-decoration: none; }
a:visited  { color: 000000; text-decoration: none; }
a:hover  { color: cccccc; text-decoration: none; }

.menu1 { color: ffffff; text-decoration: none; }
.menu1 a  { color: ffffff; text-decoration: none; }
.menu1 a:active  { color: ffffff; text-decoration: none; }
.menu1 a:visited  { color: ffffff; text-decoration: none; }
.menu1 a:hover { color: cccccc; text-decoration: none; }
Avatar billede hells Nybegynder
29. oktober 2002 - 12:14 #3
hvis du vil bestemme style for elementer ud fra hvilke elementer de ligger i skal du gøre f. eks. sådan her:
<style type="text/css">
a:link        { color: 000000; text-decoration: none; }
a:active      { color: 000000; text-decoration: none; }
a:visited    { color: 000000; text-decoration: none; }
a:hover      { color: cccccc; text-decoration: none; }
.menu1 a:link        { color: ffffff; text-decoration: none; }
.menu1 a:active      { color: ffffff; text-decoration: none; }
.menu1 a:visited    { color: ffffff; text-decoration: none; }
.menu1 a:hover      { color: cccccc; text-decoration: none; }
</style>
Avatar billede jes9 Nybegynder
29. oktober 2002 - 13:05 #4
menu1 virker ikke, er lig "000000"  ?

<html>

<head>

<style type="text/css">

a:link        { color: 000000; text-decoration: none; }
a:active      { color: 000000; text-decoration: none; }
a:visited    { color: 000000; text-decoration: none; }
a:hover      { color: cccccc; text-decoration: none; }

.menu1 a:link        { color: ffffff; text-decoration: none; }
.menu1 a:active      { color: ffffff; text-decoration: none; }
.menu1 a:visited    { color: ffffff; text-decoration: none; }
.menu1 a:hover      { color: cccccc; text-decoration: none; }
</style>


</head>


<body bgcolor="#dddddd">

<tr>
<td> <a href="http://www.dr.dk">Sort</a> </td>
</tr>

<tr>
<td class="menu1"><a href="http://www.dr.dk">Hvid</a>  </td>
</tr>

</body>

</html>
Avatar billede pelkjaer Nybegynder
29. oktober 2002 - 13:07 #5
<td><a href="http://www.dr.dk" class="menu1">Hvid</a></td>
Avatar billede jes9 Nybegynder
29. oktober 2002 - 13:10 #6
Nej det er det samme!
Avatar billede intel4004 Novice
29. oktober 2002 - 13:13 #7
Du skal angive dine hex-farve koder med en # foran koden i CSS...

Intel4004
Avatar billede intel4004 Novice
29. oktober 2002 - 13:13 #8
Altså:
a:link        { color: #000000; text-decoration: none; }
Avatar billede jes9 Nybegynder
29. oktober 2002 - 13:18 #9
Det er det samme !
Det er kun "class=menu1" der ikke virker.
Avatar billede jes9 Nybegynder
30. oktober 2002 - 13:13 #10
Fejlen er, at der står det samme (www.dr.dk) i begge "href".
Hvis de ikke er ens virker det. Hvad sker DER.......?!?!?!?!
Avatar billede intel4004 Novice
30. oktober 2002 - 14:17 #11
Når du angiver en class i css, f.eks. til et anchor-element så skriv class-navnet efter det hele...

eksempel:
a:link.menu1        { color: ffffff; text-decoration: none; }
a:active.menu1      { color: ffffff; text-decoration: none; }
a:visited.menu1    { color: ffffff; text-decoration: none; }
a:hover.menu1      { color: cccccc; text-decoration: none; }

Dette plejer at virke. Du forsøger at definere et class som et element og herefter angive style for anchor-elementer inde i en class. Men en class er jo en parameter til selve anchor(i din HTML-kode), derfor fungerer dette ikke....

Intel4004
Avatar billede intel4004 Novice
30. oktober 2002 - 14:23 #12
Ja ok...du definerer dit .menu1 som en class til et TD element...

Prøv evt. med

.menu1 > a:link, a:active, a:visited        { color: ffffff; text-decoration: none; }
.menu1 > a:hover      { color: cccccc; text-decoration: none; }

Intel4004
Avatar billede intel4004 Novice
30. oktober 2002 - 14:25 #13
Muligvis er det nødvendigt at angive tag-navn for at bruge denne metode, altså i dit tilfælde:

TD.menu1
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester