logo

04 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 97 <style> *{ margin: 0; padding: 0; } .dropdown{ width: 150px; margin: 10px auto; position: relative; } .dropdown input{ position: absolute; width: 100%; height: 50px; z-index: 10000; opacity: 0; cursor: pointer; } .dropdown .text{ font-size: 1.1rem; width: 100%; height: 50px; line-height: 50px; transition: all 0.4s; color: black; font-family: Verdana, Geneva, Tahoma, sans-serif; } .dropdown i{ width: 50px; height: 50px; position: absolute; top: 0; right: 0; color: white; transition: all 0.4s; text-align: center; line-height: 50px; } .dropdown span{ width: 50px; height: 50px; position: absolute; top: 0; right: 0; background-color: black; border-radius: 50px; z-index: -1; transition: all 0.4s; } .dropdown input:hover ~span{ width: 110%; } .dropdown input:hover ~ .text{ color: white; } .dropdown input:checked ~ i{ transform: rotate(-180deg); } .dropdown ol{ display: none; list-style: none; margin: 10px 0 0 10px; } .dropdown ol li{ height: 50px; background-color: black; margin: 0 0 10px 0; cursor: pointer; text-align: center; line-height: 50px; border-radius: 50px; } .dropdown ol li a{ color: white; text-decoration: none; font-family: Verdana, Geneva, Tahoma, sans-serif; } .dropdown input:checked ~ ol{ display: block; } .dropdown ol li:hover{ background-color: rgb(72, 72, 72); } </style> <div class="dropdown"> <input type="checkbox" name="" id=""> <div class="text">Dropdown</div> <span></span> <i class="fa fa-caret-down fa-2x"></i> <ol> <li><a href="#">lorem</a></li> <li><a href="#">lorem</a></li> <li><a href="#">lorem</a></li> </ol> </div>