Make a More option Drop Down menu using JavaScript


in this tutorial, I will show you how to make a beautiful and cool drop-down menu using javascript
we will need to use font awesome to get some icons.

HTML

<!DOCTYPE HTML>


<html>
    <head>
        <link rel="stylesheet" href="main.css">
        <script src="https://kit.fontawesome.com/425a08e296.js"></script>
    </head>
    
    <body>
            <div class="container">
                <div class="header">
                   <h1>Post Title</h1>
                   <div class="option">
                       <i onclick="Toggle()"  class="fas fa-ellipsis-h"></i>
                   <ul id="menu">
                       <li>Share</li>
                       <li>edit</li>
                       <li>Delete</li>
                   </ul>
                   </div>
                   
                </div>
                <p>
                   Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu lacus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam erat volutpat.
                </p>
                
            </div>
            
            
            <script>
               
                var menu = document.getElementById('menu')
                function Toggle(){
                    if(menu.style.display== "block"){
                        menu.style.display = "none";
                    }else{
                        menu.style.display = "block";
                    }
                }
            </script>
    </body>
    
</html>

CSS

@import url('https://fonts.googleapis.com/css?family=Nunito&display=swap');
*{
    padding0;
    margin0;
    outline0;
}

body{
    background-color: #2196f3;
}
.container{
   background-color: #fff;
   box-shadow0 6px 8px rgba(0,0,0,.1);
   padding15px 20px;
    position: absolute;
    left50%;
    top50%;
    transform: translate(-50%,-50%);
    width400px;
    font-family'Nunito',sans-serif;
}
.option{
    position: absolute;
    right56px;
    transform: translateX(100%);
    top22px;
}
.option ul{
    position: relative;
    left-40%;
    padding5px 10px;
    background-color: #fafafa;
    box-shadow0 6px 8px rgba(0,0,0,.3);
    list-style: none;
    width100px;
    display: none;
    user-select: none;
}
.option ul li{
    padding5px 10px;
    transition.4s;
    text-align: center;
    cursor: pointer;
}
.option ul li:hover{
    background-color: #e0e0e0;
}
.option i{
    padding8px;
    border-radius30px;
    transition.4s;
}
.option i:hover{
    background-color: #e2e2e2;
}
Make a More option Drop Down menu using JavaScript Make a More option Drop Down menu using JavaScript Reviewed by Medics on October 23, 2019 Rating: 5

No comments:

-->
Powered by Blogger.