WEBLEB
Accueil
Éditeur
Connexion
Pro
Français
English
Français
Español
Português
Deutsch
Italiano
हिंदी
Basculer icônes sociales CSS
8151
Sael_png
Publiez votre code
Recommandé
30 August 2024
Animation réactive en CSS pure One Div House
13 April 2024
Bouton bascule HTML CSS
18 December 2025
Pied de page d'attribution CSS : Fixe, Centré, Transparent
index.html
Copy
Webleb
Facebook
Twitter
Instagram
YouTube
TikTok
LinkedIn
styles.css
Copy
html { -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; box-sizing: border-box; font-size: 62.5%; } html * { box-sizing: inherit; } body { background: #0F2027; /* fallback for old browsers */ display: grid; font-family: sans-serif; font-size: 1.6rem; min-height: 100vh; place-content: center; position: relative; } body::before { content: ''; height: 100%; left: 0; opacity: 0.8; position: absolute; top: 0; width: 100%; z-index: 0; } .buttons { position: relative; z-index: 1; } .buttons--active .allbtns { transform: translate(-50%, -50%) rotate(0deg); } .buttons--active .button:nth-child(1) { transform: translate(-110%, -150%) rotate(0deg); } .buttons--active .button:nth-child(2) { transform: translate(10%, -150%) rotate(0deg); } .buttons--active .button:nth-child(3) { transform: translate(65%, -50%) rotate(0deg); } .buttons--active .button:nth-child(4) { transform: translate(10%, 50%) rotate(0deg); } .buttons--active .button:nth-child(5) { transform: translate(-110%, 50%) rotate(0deg); } .buttons--active .button:nth-child(6) { transform: translate(-165%, -50%) rotate(0deg); } .buttons__toggle { appearance: none; align-items: center; background-color: #000; border: 4px solid #19182b; border-radius: 50%; color: #fff; cursor: pointer; display: flex; font-size: 0; height: 8rem; justify-content: center; text-decoration: none; width: 8rem; position: relative; z-index: 1; } .buttons__toggle:focus, .buttons__toggle--active { background-color: #16228b; } .buttons__toggle i { font-size: 3.2rem; } .allbtns { left: 50%; position: absolute; top: 50%; transform: translate(-50%, -50%) rotate(180deg); transform-origin: center; transition: transform 0.75s ease; z-index: 0; } .button { appearance: none; align-items: center; background-color: #000; border: 4px solid #19182b; border-radius: 50%; color: #fff; cursor: pointer; display: flex; font-size: 0; height: 8rem; justify-content: center; text-decoration: none; width: 8rem; left: 50%; position: absolute; top: 50%; transform: translate(-50%, -50%) rotate(180deg); transform-origin: center; transition: transform 0.2s ease; } .z:focus, .button--active { background-color: #16228b; } .button i { font-size: 3.2rem; } .button:nth-child(1) { transition-delay: calc(1 * 0.075s); z-index: calc(6 - 1); } .button:nth-child(2) { transition-delay: calc(2 * 0.075s); z-index: calc(6 - 2); } .button:nth-child(3) { transition-delay: calc(3 * 0.075s); z-index: calc(6 - 3); } .button:nth-child(4) { transition-delay: calc(4 * 0.075s); z-index: calc(6 - 4); } .button:nth-child(5) { transition-delay: calc(5 * 0.075s); z-index: calc(6 - 5); } .button:nth-child(6) { transition-delay: calc(6 * 0.075s); z-index: calc(6 - 6); }
main.js
Copy
const buttonsComponent = document.querySelector('.buttons'); const buttonsToggle = document.querySelector('.buttons__toggle'); buttonsToggle.addEventListener('click', toggleButtons); function toggleButtons() { buttonsToggle.classList.toggle('buttons__toggle--active'); buttonsComponent.classList.toggle('buttons--active'); document.activeElement.blur(); }