I have an HTML, CSS, and JavaScript problem. Can anyone help me?

Good day,

I'm currently in the process of creating a website. I have a button on the website that, when clicked, opens a sidebar. When you open the website, the sidebar is already open, but I want the user to click the button first, and then the sidebar closes when you enter the website.

Thank you in advance!

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
8 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
LauraIDE
1 year ago

In this code, the sidebar is closed by default (because its width is set to 0). When the button is clicked, the width of the sidebar is set to 250px, making it visible. Maybe it was what you were looking for.




  




  

kiana517
1 year ago

Would hide the sidebar at the beginning with a class with display:none and then keep removing the class when the button is pressed. code would always be helpful

kiana517
1 year ago
Reply to  KaritoShoya

just don’t understand the question, so for a moment my answer, it’ll explain it. You make a class with display: none and take it away when the button is pressed, when the sidebar is closed you add it again.

kiana517
1 year ago

you do at css:

.sidebar-hidden {

display: none;

}

HTML: