fe-foundation | Self-cultivation of a front-end engineer | Awesome List library
kandi X-RAY | fe-foundation Summary
kandi X-RAY | fe-foundation Summary
Self-cultivation of a front-end engineer
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fe-foundation
fe-foundation Key Features
fe-foundation Examples and Code Snippets
Community Discussions
Trending Discussions on fe-foundation
QUESTION
TL DR it should be display: flex; opacity: 1
I have a menu which works in the following way:
- On mouseenter or click, the menu is shown (
display: flex
,opacity: 1
) - On mouseleave or click (outside the menu area) the menu is hidden (
display: none
,opacity: 0
)
The problem occures when I try to "open" the menu in the Dev. Tools on 320x480 resolution.
When I click
on the menu area, only #envelope
does the transformation. #links
(should also transform but don't becouse of the following reasons) which should get display: flex
actually gets display: none
assigned to it.
Note: It's working in full screen. Something is bothering him with the 320x480 res.
If I can elaborate or provide any additional information, let me know.
Thank you
...ANSWER
Answered 2020-Feb-27 at 08:47Don't use transition: all
because the browser then need to loop through all properties, and it might cause lag.
Don't use position: absolute
unless you have to.
I removed #envelope
and inserted the "Click here ..." text in a label (explanation why below).
I arranged classes so I didn't have to repeat code.
Pure CSS solution below.
I made a little CSS hack, where I used a label and a checkbox to simulate a click. So when clicking on the label#menu-toggler
, the (hidden) checkbox is checked, which triggers #menu-toggler:checked ~ #links.invisible
. I had to add another class to #links
, otherwise the low specificity wouldn't trigger the change.
QUESTION
I'm getting the following error:
Uncaught TypeError: Cannot read property 'addEventListener' of null
addEventListener
works perfectly fine on a single id (menu)... Is there a restriction that I can't use it on querySelector?
(Yes, JavaScript is at the bottom of the HTML document)
Any help will be appreciated.
...ANSWER
Answered 2020-Feb-25 at 16:22Try changing:
QUESTION
I'm currently stuck, as I can't seem to get the addEventListener to work.
I've tried the Dev. Tools with break points on addEventListener but they don't stop the script, so I guess there is something wrong with the code detecting the click
and mouseleave
and mouseenter
ANSWER
Answered 2020-Feb-25 at 13:27In your snippet, addEventListener
is working, but it looks like the code is not producing the behavior you want or expect. You don't seem to be accounting for the way events propagate through the DOM.
You can read about that here: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation
You probably want something like the following:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fe-foundation
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page