Creating a vertical animated drop-down menu is a great way to add some flair to

I've been attempting to create a dropdown menu on my website similar to the one found at https://www.geeksforgeeks.org/python-programming-language/

Here's what I'm aiming for:

https://i.sstatic.net/T5iWw.png

I can't figure out why my code isn't producing a flexible vertical drop-down menu like the one on the website linked above.

https://i.sstatic.net/IOuRc.png

The sub-menus on my website are not displaying properly, with some of them getting cut off halfway.

This is the website where I've applied the following code:

Code:

<style>
    
    body {
        background-color: #fff;
        font-size: 14px;
    }
      
     nav {
        position: relative;
        width: 180px;
    }
    
    nav ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    nav ul li {
      /* Sub Menu */
    }
    nav ul li a {
        display: block;
        background: #ebebeb;
        padding: 10px 15px;
        color: #333;
        text-decoration: none;
        -webkit-transition: 0.2s linear;
        -moz-transition: 0.2s linear;
        -ms-transition: 0.2s linear;
        -o-transition: 0.2s linear;
        transition: 0.2s linear;
    }
    nav ul li a:hover {
        background: #f8f8f8;
        color: #515151;
    }
    nav ul li a .fa {
        width: 16px;
        text-align: center;
        margin-right: 5px;
        float:right;
    }
    nav ul ul {
        background-color:#ebebeb;
    }
    nav ul li ul li a {
        background: #f8f8f8;
        border-left: 4px solid transparent;
        padding: 10px 20px;
    }
    nav ul li ul li a:hover {
        background: #ebebeb;
        border-left: 4px solid #3498db;
    }
    
    
    
    
    
    </style>
    
    
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
    <nav class='animated bounceInDown'>
        <ul>
            <li><a href='#profile'>Profile</a></li>
            <li><a href='#message'>Messages</a></li>
            <li class='sub-menu'><a href='#settings'>Settings<div class='fa fa-caret-down right'></div></a>
                <ul>
                    <li><a href='#settings'>Account</a></li>
                    <li><a href='#settings'>Profile</a></li>
                
                </ul>
            </li>
        
            <li class='sub-menu'><a href='#Somethin'>Something<div class='fa fa-caret-down right'></div></a>
                <ul>
                    <li><a href='#settings'>Account</a></li>
                    <li><a href='#settings'>Profile</a></li>
                
                </ul>
            </li>
        
        
            <li class='sub-menu'><a href='#message'>Help<div class='fa fa-caret-down right'></div></a>
                <ul>
                    <li><a href='#settings'>FAQ's</a></li>
                    <li><a href='#settings'>Submit a Ticket</a></li>
                    <li><a href='#settings'>Network Status</a></li>
                </ul>
            </li>
        
        </ul>
      
    </nav>
    
    
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    
    <script>
    
    
    
    $('.sub-menu ul').hide();
    $(".sub-menu a").click(function () {
        $(this).parent(".sub-menu").children("ul").slideToggle("100");
        $(this).find(".right").toggleClass("fa-caret-up fa-caret-down");
    });
    
    </script>

Answer №1

Here are some essential styling changes to add:

.widget ul {
    padding: 0 !important;
}

#sidebar-left-1 .widget-content nav {
    width: unset !important;
}

#sidebar-left-1 {
    margin: 0 !important;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for styling a button upon being clicked

Is there a CSS technique to make a button change color when clicked with the mouse? I am aware of using ':hover' for changing color, but I need something specific to a left mouse click. I want the same functionality as a standard button but with ...

Ensure proper spacing between the axis and text on your NVD3 charts by adding a space

My attempt to identify the classes responsible for styling the axis was unsuccessful. It left me feeling lost. I struggled to pinpoint the correct class to use in order to create some space between the axis and the text. Any suggestions on how I could ta ...

Turning jQuery Mobile XML into a Table

Recently, I switched from using the jQuery Mobile framework's grid layout to a table layout. However, I encountered an issue where only the first line of data from my XML parse was being displayed. There are actually 8 pieces of data that should be sh ...

Instructions on creating an "already clicked" style for an <a> href

Is there a solution to display my href as already clicked? I'm looking for a property or method that does not involve css or javascript. ...

JQuery cannot target content that is dynamically inserted through an Ajax request

When I use an ajax call to pass dynamically generated html, such as in the example below: var loadContent = function(){ $.ajax({ url: '/url', method: 'GET' }).success(function (html) { $('.con ...

Why is the Django image URL redirecting to an HTML template instead of the media file?

I created a Django application with a template that includes an image. However, I encountered an issue where the server is attempting to display the image using the redirect link from the HTML template instead of retrieving it from the media file. For ins ...

What are the steps to properly centralize a "brief biography"?

I've been struggling to align my short bio on my webpage. I used Bootstrap to create a column layout with a picture and text, but I can't seem to center it properly. Various attempts were made, including using float: left and float: right, as we ...

Disable the button when there is no input provided

How can I disable the button when the text length is less than or equal to 0 in Vue.js and set its properties within the tag? Here's the button code: <button> Add task </button> ...

Trying to connect a webpage to my CSS file

Lately, I've been diving into building a new website. It's still in its early stages and unfortunately, I'm struggling to get the style.css file to cooperate. Despite my best efforts scouring the internet for fixes, I haven't had much l ...

What are some strategies for keeping the focus state on the parent item in a dropdown menu?

When I interact with the dropdown menu in my navigation bar, the color changes for the child items. How can I make sure that the parent item maintains the same colored background even after clicking elsewhere on the page? To better understand the issue, i ...

Transform bootstrap CHECKBOX into the appearance of a bootstrap BADGE

Is there a way to create Bootstrap checkboxes that resemble bootstrap badges, while still functioning as checkboxes? I attempted to style the checkbox label as a badge, but it was unsuccessful. <head> <link rel='stylesheet' href= ...

Is there a way to use Media Queries to require CSS to load an image?

Here is the CSS code I am using: html { background: url(../img/header_mobile.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } /* Smal ...

How can I use HTML and jQuery to send a button click event to a .py file using AJAX and cgi in web development?

I have encountered a challenge with posting data from button clicks on an HTML page to Python CGI for insertion into a PostgreSQL database. My script seems to be struggling with this task. Here is the structure of my HTML, ajax, and javascript: '&ap ...

Utilizing CSS transitions to smoothly adjust the width of an element until it completely fills the container div in ReactJS

import React from 'react'; import PropTypes from 'prop-types'; import SearchIcon from '@material-ui/icons/Search'; import InputBase from '@material-ui/core/InputBase'; import { AccountCircle } from '@material-ui ...

Find the total sum of various spans

As a beginner in programming, I am facing a challenge that I cannot seem to solve. How can I retrieve the values of multiple spans with the same class? This is how the HTML code looks: <ul> <li> <input type="checkbox" value="30 ...

I need help with formatting a div to look like this

Looking to simplify my page by reducing the number of divs, wondering if this "tile" could be achieved without using one. Here's the example I have in mind: <a href="mks.html" class="big-tile big-tile-1"> <h1>town<br> libra ...

Is 100% truly the same as 100%?

When positioning two divs side by side with widths set in percentages, a total of 100% is often too wide and results in the divs not sitting next to each other as intended. Reducing the total width to 99% can create an uncomfortably large gap between the ...

Ways to obtain the ID of the following element using jQuery

Here is some HTML code, and I am trying to retrieve the ID of the next element from a clicked element with the class name "coba" or to get the ID of an element with the class name "coba2." <div class="dropdown"> <label>Category</label> ...

assigning a label to a DropDownList

When attempting to place a label in front of a DropdownList, the dropdownlist appears on the next line. I have tried various suggestions from different sources but have not been able to find a solution. Here is the simple code I am currently using: Group ...

The button appears flawless in Chrome and Firefox, but unfortunately fails miserably in Internet Explorer. Is there any way to make it functional in all

Check out this JFiddle link: http://jsfiddle.net/Zfnz2/ I'm seeking ideas from the wise minds of the internet. Any thoughts? ...