Creating a sleek drop-down menu using HTML and CSS

I am currently working on creating a drop-right menu using CSS, but I seem to be stuck...

After searching for examples on the internet, I found that most of the code snippets are quite lengthy and overwhelming.

I attempted to implement one of them, but the outcome was far from satisfactory as you can see...

How can I go about fixing this issue?

I have also included a link to an example of the desired result:

Thank you in advance!

body {
    background-color: #CEF6F5;
    text-decoration: none;
}
aside {
    margin-top: 1%;
    height: 50%;
}
#content {
    float: right;
    width: 80%;
    background-color: red;
}
#menu {
    width: 20%;
    float: left;
    background-color: black;
}
.menu {
    text-decoration: none;
    background-color: #000000;
    font-family: 'Rancho', cursive;
}
.cl-menu {
    list-style: none outside none;
    display: inline-table;
    position: relative;
    width: 80%;
}
.cl-menu li {
    padding: 5px 1px;
    text-align: center;
}
.cl-menu > li:hover {
    background-color: #303030;
    background-color: #66819C;
    color: #FFF;
    font-weight: bold;
    text-decoration: none;
    opacity: 1;
}
.cl-menu li ul {
    display: none;
}
.cl-menu li:hover ul {
    display: block;
    opacity: 0.8;
    background-color: #FFF;
    margin-top: 4px;
    margin-left: 200px;
    font-weight: normal !important;
}
.cl-menu li ul li {
    border-bottom: 1px solid #cccccc !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
}
.cl-menu li ul li a {
    color: #green;
}
.cl-menu li ul li a:hover {
    color: #5j8548;
}
.cl-menu ul:after {
    content: "";
    clear: both;
    display: block;
}
a {
    text-decoration: none;
    color: #CEF6F5;
    font-family: 'Rancho', cursive;
}
<link href='http://fonts.googleapis.com/css?family=Rancho' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css.css">
<html>

<body>

    <aside id='menu'>
        <ul class="cl-menu">

            <li> <a href="#">Mis pedidos</a> </li>
            <li> <a href="#">Mi perfil</a> </li>
            <li> <a href="#">Descuentos</a>
            </li>
            <li id='albumes'>Albumes
                <ul>
                    <li><a href="#">Navidad 2015</a>
                    </li>
                    <li><a href="#">Navidad 2014</a>
                    </li>
                </ul>
            </li>
            <li> <a href="#">Añadir al carrito</a> </li>
            <li> <a href="#">Articulos seleccionados</a> </li>
            <li> <a href="#">Finalizar Pedido</a> </li>z
        </ul>
    </aside>

    <aside id="content">WEB CONTENT</aside>

</body>
    
</html>

Answer №1

After noticing a significant amount of unnecessary code, I took the initiative to clean it up and make necessary fixes. Here is the revised version:

HTML:

<aside id='menu'>
    <ul class="cl-menu">
        <li>
            <a href="#">My Orders</a>
        </li>
        <li>
            <a href="#">My Profile</a>
        </li>
        <li>
            <a href="#">Discounts</a>
        </li>
        <li id='albums'>
            <a href="#">Albums</a>
            <ul>
                <li>
                    <a href="#">Christmas 2015</a>
                </li>
                <li>
                    <a href="#">Christmas 2014</a>
                </li>
            </ul>   
        </li>
         <li>
            <a href="#">Add to Cart</a>
        </li>
         <li>
            <a href="#">Selected Items</a>
        </li>
         <li>
            <a href="#">Complete Order</a>
        </li>
    </ul>
</aside>
<aside id="content">WEBSITE CONTENT</aside>

CSS:

body
{
    background-color: #CEF6F5;
}

aside
{
    margin-top: 1%;
    height:50%;
}

ul
{
    margin: 0;
    padding: 0;
}

li
{
    list-style:none;
}

a
{
    text-decoration:none;
}

#content
{
    float:right;
    width:80%;
    background-color:red;
}

#menu
{
    width:20%;
    float:left;
    background-color: #000;
}

.cl-menu li
{
    position: relative;
}

.cl-menu > li:hover
{
    font-weight:bold;
    opacity: 1;
    filter: alpha(opacity=100);
}

.cl-menu li:hover
{
    background-color:#66819C;
}

.cl-menu li a
{
    display: block;
    min-width: 150px;
    padding: 10px;
    color:#CEF6F5;
    font-family: 'Rancho', cursive;
}

.cl-menu li:hover a
{
    color:#FFF;

}

.cl-menu li ul
{
    position: absolute;
    top: 0;
    left: 100%;
    border: 1px solid #000;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    display:none;
}

.cl-menu li:hover > ul
{
    display:block;
    opacity: 0.8;
    filter: alpha(opacity=80);
}

.cl-menu li ul li
{
    background: grey;
    border-bottom:1px solid #000;
    border-top:none;
    border-left:none;
    border-right:none;
}

.cl-menu li ul li:last-child
{
    border-bottom: none;
}

Live Example: http://jsfiddle.net/q6ouetwp/1/

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

Incorporating Twitter Bootstrap into your Zend Framework 2 Navigation Menu

I have successfully created a menu from my database and the code is functioning perfectly. Now, I'm looking to enhance the menu's style by incorporating Twitter Bootstrap, but I'm encountering some difficulties in doing so. Is there anyone k ...

The cakePHP time dropdown feature lacks customization options

When viewing my form in CakePHP, I noticed that the time select dropdown appears differently in Chrome compared to Firefox. In Firefox, there are 3 arrow buttons attached to each dropdown, whereas in Chrome it looks different. I want to hide the arrow but ...

What is the secret to keeping links opaque even after they have been hovered over and their target is visible?

There are four links on my page that toggle the visibility of different divs. You can see them in action here. The code for the links is shown below: <li class="togglelink fadein button" data-block="albums" id="togglealbums">Albums</li> <l ...

Add HTML content dynamically to a layout that is connected to a controller

While I may not have the proper heading for this question, I need to add this piece of HTML dynamically to my layout and attach its click events with a controller. <div id="subscriber1" class="participant-video-list"> <div class="participant- ...

Determining the existence of a file on a different domain using JavaScript

One of the key tasks I need to achieve from JavaScript on my HTML page is checking for the existence of specific files: http://www.example.com/media/files/file1.mp3 // exists http://www.example.com/media/files/file2.mp3 // doesn't exist Keep in mi ...

What is the best way to evenly distribute items in nested CSS Grid Columns?

Check out this JSFiddle link for a simple Google.com recreation. I'm attempting to organize the top navigation bar by creating separate containers for About, Store, Gmail, and Images. The issue seems to be related to the justify-items:center; propert ...

Black and white emoji display on Windows 7 using Chrome and Edge browsers

To enhance the visual appeal of my website, I incorporate emojis using Emoji Unicode from https://www.w3schools.com/charsets/ref_emoji.asp. It has come to my notice that on Android, Mac, and iPhone devices, users see colored emoticons while those on Window ...

Having trouble with the focusout() function not registering on the search box?

When using the focusout function, I encountered an issue where clicking on a title in the search results would prevent redirecting to the title page. Although the function worked properly when closing the search results by clicking on a different element o ...

Maintain font kerning for span elements that are not displayed inline

I am looking to add some transform effects to individual letters in a word. To achieve this, I have enclosed each letter within a span element. However, when setting the display of these spans to inline-block, the font kerning gets disrupted. I have exper ...

The CSS in Django seems to be malfunctioning on various pages, particularly on header elements

My CSS file is linked in 'main/static/css/style.css' and my pages are located in 'main/templates/main/pages.html'. However, the CSS does not seem to be working properly for some pages; for example, the h2 tag is not taking on the specif ...

Changing the CSS background in React when updates occur

Currently working on toggling the CSS background image within this React application. The images have been successfully imported and a variable called "image" is set to the imported image as the iteration increases/decreases with each click. The issue I&a ...

Incrementing the image name by 1 each time a new image is added to the directory

Currently honing my PHP skills and in the learning process. Developed a simple script that enables users to upload images to a directory on the server. I aim to append a number at the end of each image name to prevent duplication. Here is my attempt at i ...

If the cursor hovers over an image, the onmouseover function does not work properly

Currently, I am developing a PHP page to display data from a database in a tabular format. Each column in the table represents an 'ATC Station'. When active, additional data is displayed upon hovering over the cell. Everything was running smooth ...

What is the best way to create transparency within an icon's background without affecting the surrounding box?

Is there a way to set the background color of the icon inside the circle without affecting the transparent box around it? Currently, when I use background:white, it changes both the circle and the surrounding box. https://i.sstatic.net/mlV1I.png ...

What are the best ways to ensure text stays center aligned and prevent position absolute elements from overlapping?

I'm currently working on a project that involves center-aligning the page title within the parent div. However, I have run into an issue with an overlapping back button when the page title is too long due to its absolute positioning. Can anyone provid ...

Tips for creating responsive text within a hero image

I'm exploring the world of creating responsive websites using Bootstrap, a new venture for me. One challenge I've encountered is trying to create a hero image with text positioned perfectly in the center. Despite my efforts, the text does not adj ...

The Form button in my PHP email code is failing to produce any output when submitted

I attempted to create a contact form using a combination of HTML and PHP. Everything was functioning as expected during testing with the code input type="submit" name="submit" value="Submit" However, when I switched to using div and button with the class ...

Safari enables seamless text flow into the footer without triggering scrolling as long as the length is manageable

Encountering a unique issue solely in Safari 6.0.5 on OS X 10.8.4 within certain conditions, which doesn't exist when tested on Firefox or Chrome under various scenarios in OS X. The column layout with floats is the crux of the problem. When the text ...

Add a React component to the information window of Google Maps

I have successfully integrated multiple markers on a Google Map. Now, I am looking to add specific content for each marker. While coding everything in strings works fine, I encountered an issue when trying to load React elements inside those strings. For ...

Executing Javascript in Python Environment

I'm currently working on developing an HTML document parser using Python. Since I have a strong understanding of jQuery, I am interested in leveraging its traversal capabilities to parse these HTML files and then send the gathered data back to my Pyth ...