0

How can I close an <details> when the screen is smaller than x? I think it could be done using css @media but I am not sure how.

25th Aug 2021, 1:48 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
5 odpowiedzi
+ 4
Create 2 similar details blocks, one with open attribute, and the other without. Use @media to select the display block and none. .details-open { display: block; } .details-closed { display: none; } @media only screen and (max-width: 600px) { .details-open { display: none; } .details-closed { display: block; } } https://code.sololearn.com/WCtY2i9Q1Rud/?ref=app
26th Aug 2021, 1:05 AM
Calviղ
Calviղ - avatar
+ 4
Lisa Check this out, notice the change while I drag the screen. https://www.loom.com/embed/4d7744536e1a486e8af7935058cf39ca
26th Aug 2021, 11:44 AM
Calviղ
Calviղ - avatar
+ 3
Calviղ Cool! Thanks! 👍
26th Aug 2021, 11:50 AM
Lisa
Lisa - avatar
+ 2
"open" is rather an attribute of details, a functionality, not a style property I don't know how to set it with css... https://www.w3schools.com/TAGS/tag_details.asp
25th Aug 2021, 2:22 PM
Lisa
Lisa - avatar
+ 2
Would changing the display render the details completely invisible instead of just closing g them?
26th Aug 2021, 6:08 AM
Lisa
Lisa - avatar