#toggling class in js working but results are weird

27 messages · Page 1 of 1 (latest)

twilit crag
#
.active-dropdown {
    display: flex;
    flex-direction: row; /** this also works **/
}

.dropdown {
    background-color: var(--eerie-black);
    width: 300px;
    padding: 20px;
    line-height: 20px;
    height: 100%;
    right: 0;
    position: absolute;
    /**
    display: flex; this works
    flex-direction: column;
    **/ 
    z-index: -1;
}
function toggleDropdown(x) {
    
    x.classList.toggle('change'); // ignore this its for smthn else

    let dropdown = document.getElementsByClassName('dropdown')[0];
    dropdown.classList.toggle('active-dropdown');

}
#

i want the active dropdown class to make it visible but it dont work

#

that above works but not how i want it too

#

so its this now ```css
.active-dropdown {
display: flex;
flex-direction: row;
}

.dropdown {
background-color: var(--eerie-black);
width: 300px;
padding: 20px;
line-height: 20px;
height: 100%;
right: 0;
position: absolute;
display: none;
z-index: -1;
}

#

but it dont

long holly
#

What's it not doing that you want it to do?

twilit crag
#

well if when i toggle the active-dropdown class, it should display, because obvs display is none on the dropdown class that is has, but it just dont show

long holly
#

I meant the first one, what's wrong with the first one

long holly
#

"that above works but not how i want it too"

#

Whatever you were referring to there

twilit crag
#

ohhhh yeah mb

#

i made the flex-direction change to make sure it was actually applying and it changes, and it changes

#

so i need to figure out how to change the display one basically, but so it works

long holly
#

Oooh okay. This is gross but might work... try...

.active-dropdown {
    display: flex !important;
    flex-direction: row;
}

.dropdown {
    background-color: var(--eerie-black);
    width: 300px;
    padding: 20px;
    line-height: 20px;
    height: 100%;
    right: 0;
    position: absolute;
    display: none;
    z-index: -1;
}
twilit crag
#

wait what

#

huhhh

long holly
#

Did it work?

twilit crag
#

yeah ty

long holly
#

There's probably a good and proper way to do what you want to do but I don't know what it is

twilit crag
#

well it works thats better than it not working lol

#

tyvm ❤️

high gullBOT
long holly
#

Maybe keep the thread open incase somebody that knows how to do it properly comes along 😅

twilit crag
#

yeah i will, can i ask another question here aswell? dosent make sense to make another thread because its probs like a 1msg answer

long holly
#

Yeah go for it