JSFiddle - React, Tailwind, and code Playground

by nadineducegep

HTML

<h1>Réseau social</h1>
	<h2>Inscription</h2>

	<form id="formulaire-identification">
	
		<div id="choix-sexe">
		
			<label style="display:block;">Vous êtes : </label>

			<input type="radio" id="homme" name="sexe" value="homme"/>
			<label id="libelle-homme" for="homme" class="selecteur-sexe"><span>Homme</span></label>			
			<input type="radio" id="femme" name="sexe" value="femme"/>
			<label id="libelle-femme" for="femme" class="selecteur-sexe"><span>Femme</span></label>	
		
		</div>
	
	</form>

CSS

/* On fait disparaitre le rond a cliquer */
		#choix-sexe input
		{
		    -webkit-appearance:none;
			-moz-appearance:none;
			appearance:none;
		}
		
		/* On prepare les label qui vont devenir les images */
		#choix-sexe label.selecteur-sexe
		{
		    display:inline-block;
			width:100px;
			height:199px;
			cursor:pointer;
			opacity:0.2;
		}
		/* On fait disparaitre le texte du label */
		#choix-sexe label.selecteur-sexe span
		{
			display:none;
		}

		/* On specifie une image differente pour chaque radio */
		#choix-sexe label#libelle-femme
		{
			background-image:url('https://i.postimg.cc/fbbjy1Wr/mini-femme.png');
		}
		#choix-sexe label#libelle-homme
		{
			background-image:url('https://i.postimg.cc/gchyxVdm/mini-homme.png');
		}
		
		/*************************************/
		/* EFFET */
		/*************************************/
		
		/* On illumine le libelle survole */
		#choix-sexe label.selecteur-sexe:hover
		{
			opacity:1;
		}
		
		/* Le libelle a cote de l'input coche reste illumine */
		#choix-sexe input:checked+label.selecteur-sexe
		{
			opacity:1;
		}
		#choix-sexe input:active+label.selecteur-sexe
		{
			opacity:1;
		}