28118 sujets

CSS et mise en forme, CSS3

Salut

J'ai stylisé mes liens pour que au hover le noir disparaisse de la gauche vers la droite et que le rouge prenne sa place de la gauche vers la droite aussi. Le noir disparaît bien comme je le veux, mais le rouge n’apparaît pas. Ça reste blanc.

Le code (Voir sur jsfiddle) :

p a {
	text-decoration:none;
	border-bottom:0;
	background: linear-gradient(180deg, rgb(0,0,0) 100%, rgb(255,0,0) 100%);
	background-size: 100% 14%, 0 14%;
	background-position: bottom left, bottom left;
	background-repeat: no-repeat, no-repeat;
  
	transition-duration: 1s;
	transition-property: background-size;
}

p a:hover {
	text-decoration:none;
	border-bottom:0;
	background: linear-gradient(180deg, rgb(0,0,0) 100%, rgb(255,0,0) 100%);
	background-size: 0 14%, 100% 14%;
	background-position: bottom right, bottom left;
	background-repeat: no-repeat, no-repeat;
    
    transition-duration: 1s;
    transition-property: background-size;
}
Bonjour,

Une solution possible :
p a {
  text-decoration: none;
  border-bottom: 0;
  background: linear-gradient(90deg, rgb(255, 0, 0) 50%, rgb(0, 0, 0) 50%);
  background-size: 200% 12%;
  background-position: bottom right;
  background-repeat: no-repeat;

  transition-duration: 1s;
  transition-property: background-position;
}

p a:hover {
  background-position: bottom left;
}

https://jsfiddle.net/jfw725z6/
Modifié par Pitet (12 Jul 2022 - 12:53)
Meilleure solution