logo

03 Jan 2022

HTML & CSS:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 <style> *{ margin: 0; padding: 0; } body{ background: black; } .main{ width: 100%; height: 100vh; display: flex; justify-content: center; align-items: center; } .toggle{ width: 50px; height: 50px; background: #c70039; border-radius: 50%; border: 2px solid #c70039; cursor: pointer; position: relative; } .toggle::before{ content: '\f1e0'; width: 100%; height: 100%; position: absolute; color: white; font-family: fontAwesome; text-align: center; line-height: 50px; font-size: 22px; } .share.active .toggle::before{ content: '\f00d'; font-size: 2rem; } .share{ position: relative; } .share ol{ position: absolute; margin: 2px; width: 50px; height: 50px; } .share ol li{ position: absolute; width: 50px; height: 50px; background: white; display: flex; justify-content: center; align-items: center; border-radius: 50%; transition: all .4s; } .share ol li a{ color: black; } .share.active ol li{ transform: translate(0); transition: all 0.4s; } .share.active ol li:nth-child(1){ transition-delay: 0.1s; transform: translateX(60px); } .share.active ol li:nth-child(2){ transition-delay: 0.2s; transform: translateY(60px); } .share.active ol li:nth-child(3){ transition-delay: 0.3s; transform: translateX(-60px); } .share.active ol li:nth-child(4){ transition-delay: 0.4s; transform: translateY(-60px); } </style> <div class="main"> <div class="share"> <ol> <li><a href="#"><i class="fab fa-instagram fa-2x"></i></a></li> <li><a href="#"><i class="fab fa-facebook fa-2x"></i></a></li> <li><a href="#"><i class="fab fa-whatsapp fa-2x"></i></a></li> <li><a href="#"><i class="fab fa-twitter fa-2x"></i></a></li> </ol> <div class="toggle"></div> </div> </div>

JS Code:

1 2 const toggle = document.querySelector('.toggle'); toggle.addEventListener('click',()=>{ const sharebtn = document.querySelector('.share'); sharebtn.classList.toggle('active');})