Farbe automatisch ändern-CSS/HTML?
Hallo, ich möchte, dass meine Überschrift die Farbe wechselt, aber nicht der Hintergrund, sondern die Buchstaben selber. Wie funktioniert das?
1 Antwort
Von gutefrage auf Grund seines Wissens auf einem Fachgebiet ausgezeichneter Nutzer
Computer, HTML, programmieren
Hintergrund ist background-color, Schriftfarbe ist color. Du willst letzteres, also einfach
h1 {
color: red;
}
Oder willst du dass die Farbe dauerhaft hin- und her wechselt, beispielsweise von blau zu rot zu blau zu rot, etc.?
Falls du sowas willst brauchst du eine CSS Animation:
h1 {
color: blue;
animation: colorChange 1s infinite;
}
@keyframes colorChange {
50% { color: red; }
100% { color: blue; }
}
Woher ich das weiß:Hobby – Programmieren ist mein Hobby & Beruf