dropdown list | dropdown list html css







 dropdown list | dropdown list html




Welcome🎉 to Code With Random blog. In this blog, we learn that how we how to create dropdown list . We use HTML & CSS  for this dropdown list . Hope you enjoy our blog so let’s start with a basic HTML structure for dropdown list .

HTML code for dropdown list

 <!DOCTYPE html>  
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DropDown List</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="container">
<input type="checkbox" name="" id="" class="btn">
<div class="list">
<a href="#"><i class="fas fa-user-alt"></i>&nbspProfile</a>
<a href="#"><i class="fas fa-envelope"></i>&nbspMessages</a>
<a href="#"><i class="fas fa-cog"></i>&nbspSettings</a>
<a href="#"><i class="fas fa-sign-out-alt"></i>&nbspLog Out</a>
</div>
</div>
</body>
</html>

There is all HTML code for the dropdown list . Now, you can see output without CSS, then we write CSS for our dropdown list .


dropdown list | dropdown list html css



CSS for dropdown list 

 @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');  
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container{
width: 200px;
position: relative;
}
.btn{
width: 100%;
height: 35px;
cursor: pointer;
position: relative;
display: flex;
}
.btn::before{
content: 'Drop Down';
display: flex;
align-items: center;
width: 100%;
height: 100%;
background: white;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.062);
border: 2px solid #FF5F6D;
padding-left: 1em;
background: linear-gradient(to right, white 80%, #FF5F6D 20%);
}
.btn::after{
content: 'f062';
position: absolute;
right: 0;
display: flex;
align-items: center;
justify-content: center;
font-family: 'Font Awesome 5 Free';
font-weight: 700;
width: 20%;
height: 110%;
color: white;
transform: rotate(180deg);
transition: all .4s;
}
.btn:checked::after{
transform: rotate(0deg);
}
.list{
position: absolute;
margin-top: 0.5em;
width: 100%;
height: 175px;
clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
display: flex;
flex-direction: column;
transition: all .4s;
}
input:checked ~ .list{
clip-path: none;
}
.list a{
height: 25%;
display: flex;
align-items: center;
padding: 0.3em 0 0.3em 1em;
text-decoration: none;
margin: 0.3em 0;
background: white;
color: rgb(36, 36, 36);
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.062);
transition: background .4s;
}
.list a:hover{
background: #FF5F6D;
color: white;
}

Now we have completed our CSS section,  Here is our updated output CSS.



dropdown list | dropdown list html css

dropdown list | dropdown list html css


 Hope you like dropdown list , you can see output video and project screenshots. See our other blogs and gain knowledge in front-end development. Thank you 🙏💕


Share on:

Leave a Comment