The collapsing menu is malfunctioning due to duplicate selectors

Although I have been learning HTML, CSS and jQuery, one area that always trips me up is selectors. Currently struggling with redundant selectors.

I am attempting to customize the ul and li elements after collapsing the li, however, the selector doesn't seem to be functioning as expected.

  • Any suggestions on how to rectify this? Shouldn't the .colapsed selector override the other selectors?

http://jsfiddle.net/jcml/bby7522h/

<div class="menu m1 corner">
        <div class="links">
            <ul>
                <li class="toSub colapsed" data-open=".m3">Architecture
                <ul>
                    <li class="toSlide" data-open=".s1">bla</li>
                    <li class="toSlide" data-open=".s2">bla</li>
                    <li class="toSlide" data-open=".s3">bla</li>
                    <li class="toSlide" data-open=".s4">blablablablablabla</li>
                </ul></li>
                <li class="toSub" data-open=".m4">Coding</li>
                <li class="toSlide" data-open=".s5">bla</li>
                <li class="toSlide" data-open=".s6">bla</li>
                <li class="toSlide" data-open=".s7">bla</li>
                <li class="toSlide" data-open=".s8">blablablablablabla</li>
                <li class="toSub" data-open=".m5">Thesis</li>
                <li class="toSlide" data-open=".s9">bla</li>
                <li class="toSlide" data-open=".s10">blablablablablabla</li>
            </ul>
        </div>
    </div>

ul {
    padding: 0;
    margin: 0;
}

.menu > .links {
    font-family: 'Montserrat', sans-serif;
    font-size: 2em;
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    height: 100%;
}


.links ul {
    position: relative;
}

.menu li {
    list-style: none;
    display: table;
    position: relative;
    left: 50%;
    padding: 15px;
    margin: 5px;
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
    transform: translateX(-50%);
 }

.menu li, a{
    cursor: pointer;
    color: rgba(255,255,255,.75);
    -webkit-transition: all ease .75s;
    -moz-transition: all ease .75s;
    -ms-transition: all ease .75s;
    -o-transition: all ease .75s;
    transition: all ease .75s;
    text-decoration: none;
}

.menu li:hover, .menu a:hover {
    color: rgba(255,255,255,1);
}

.colapsed .ul .li {
    color: black;
    font-size: .1em;
    padding: 0px;
    margin: 0px;
}

Answer №1

Your selector is incorrect:

.colapsed .ul .li {

The correct format should be:

.colapsed ul li {

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

When my viewport's size is less than 998px, a blank space appears

While configuring media queries in my HTML and CSS project, everything seemed to be working well. However, I noticed that when I shrink the screen, there is an empty white space on the right side and a horizontal scroll bar appears at the bottom without an ...

Different methods of displaying the next image from a URL without explicitly setting the dimensions

I am attempting to display an image in Next.js without specifying the width and height by using import Image from 'next/image';. It should be noted that the image is sourced from a URL, not a specific folder within the project. <Image si ...

CSS unexpectedly adds a border to a div element that does not have any border properties set

Currently, I have a bar with buttons that I refer to as the control bar. My intention is for it to be fixed at the bottom of the screen and span the entire width. However, there seems to be some unwanted white space on the bottom and right edges of the bar ...

Utilizing the power of JavaScript, CSS, and HTML to seamlessly transfer selected items from one webpage to the shopping cart displayed on another page

Due to limitations on using back-end code, I'm seeking advice on how to implement this function. Most tutorials I've come across show the items and shopping cart on the same page. I've heard suggestions about using Jquery.load(), but I&apos ...

Challenges with Implementing Background Images on my Website with HTML and CSS

Being new to the world of coding, I recently created a website for a college presentation. However, after uploading the website onto the internet, I noticed that the background images from my files are not displaying on the website. It's likely that I ...

"Utilizing Bootstrap to add borders to div elements is a

https://i.sstatic.net/yPt46.png Hey there! I am working on a project using bootstrap 4. I encountered an issue that I can't seem to solve. I placed an image inside a div, set the div's height and width to 200px with overflow hidden. The image w ...

utilizing symbols from a vector graphic icon库

There are countless icon images to be found on the internet. Recently, I came across this particular set and now I'm stumped on how to actually utilize them. Despite my efforts to find tutorials online, I have come up short in finding any helpful reso ...

Transparent CSS Table Styling

Can you create a CSS effect where all content inside a table becomes transparent on hover? For example: <table><tr><td> AN IMAGE </td> <td> SOME TEXT </td></tr></table> So if either the image or the text ar ...

Update the icon using CSS style properties

I have been using liqour-tree and I need to change the arrow icon to a custom one. Unfortunately, I am not sure how to do this. Can someone please help me out? I have identified the element tag where the icon is placed. <i class="tree-arrow expanded ha ...

Adjust the button's color even after it has been clicked

My goal is to update the button's color when it's clicked. I found some examples that helped me achieve this, but there's an issue - once I click anywhere outside of the button, the CSS class is removed. These buttons are part of a form, and ...

JavaScript | Determining the coordinates of where on the image X and Y were clicked

My goal is to determine the position of an x and y location when a user clicks on an image. This information will be used to add a spot to the image that displays relevant information. The content for the spot will be dynamically loaded from a SQL database ...

How to achieve divs with see-through text using CSS?

How can I create a CSS (non-HTML5) based website with a filled div that has a cutout revealing an image underneath? There are various overlays and images involved, making the use of static images inconvenient. Additionally, I anticipate needing to scale th ...

Setting a div's width to cover 100% of the screen's width

I'm currently working on creating a 2 column layout using divs. The left column has a fixed size of 150 px, while the right column should extend to the right boundary of the browser. I've tried using both width:auto and width:100% values for the ...

What is the best way to position a search icon on the right side using CSS?

I am trying to figure out how to display a search icon image on the right side using CSS, but so far I have been unsuccessful. Here is the code that I have: The CSS code: .search { background: url(../images/icons/search.png) no-repeat; display:in ...

What is the best way to connect to a specific part of a webpage that functions properly on Safari?

On my website, I have a testimonials page with a featured testimonial on the homepage that has a "Read More" option. When users click on this link, I want them to be taken directly to the testimonials page and to the specific section where that particular ...

Arrange a series by the actual pixel width of the string

Imagine you have an array of tags represented as strings and you need to display them in a narrow view. Some tags are smaller, allowing for 2 to fit on one line, while larger tags require their own line. Your goal is to sort the array so that the smalles ...

Having issues with floats in Bootstrap?

I'm facing an issue trying to float two elements within a Bootstrap navigation bar, but for some reason it's not working. .cls1 { float: left !important; } .cls2 { float: right !important; } <link href="https://maxcdn.bootstra ...

What is the best way to reduce the size of an image using a URL?

As I work on creating a website in React for a company, my main focus is on developing a drive repository where users can upload files. One issue that has arisen is the performance of the "photos" folder, as it contains numerous high-resolution images th ...

"Styling a form input with YAML and implementing a jQuery date picker field

Seeking help with a CSS question related to YAML. I've been struggling all day trying to position a jQuery date field next to a YAML CSS field, but so far I can only manage to have it display underneath the input field... Is there a way for the date ...

How to retrieve nested menu items within the scope by utilizing JSON and AngularJS

I have recently started working with angular and am facing difficulty in accessing the submenu items within my angular application. While I can successfully access the top level menu items, I am struggling to retrieve the second level items. Here is a sni ...