- 1

How to make CSS component invisible?[SOLVED]

I have a side bar that contain a form. I want to make this sidebar invisible when pressing a button. When I do so the form inside the sidebar is still visible. How can I make the sidebar and all of the data inside it invisible at the same time? All help will be greatly appreciated. Thank you in advance.

29th Apr 2020, 9:42 PM
MBanski
MBanski - avatar
13 Respostas
+ 11
there are many ways No 1: display:none; No 2: visibility:hidden; No 3: opacity:0; PS: if you use No 1 way, the element will not take any space but with other ways, the space taken by the element will be remain same
29th Apr 2020, 9:45 PM
Farhan
Farhan - avatar
+ 4
Without your code nobody could give you accurate answer, because there isn't a single way to do: it depends on how you did implement your side bar with your form ^^ (there's even some cases hardest to handle, and probably at least minimal changes to do to your actual structure and/or css ti be able achieve your goal ;P)
30th Apr 2020, 2:54 AM
visph
visph - avatar
+ 3
Use display:block; instead
29th Apr 2020, 9:57 PM
Farhan
Farhan - avatar
+ 3
If the question is solved you should add [SOLVED] to the question title ;) If not, we needs the complete code, not a description of how you managed it ^^
30th Apr 2020, 11:12 AM
visph
visph - avatar
+ 1
if i understand yuor problem. the solution is to add this to your side bar: overflow: hidden; maybe this will help too: https://www.w3schools.com/howto/howto_js_collapse_sidebar.asp
29th Apr 2020, 10:13 PM
yochanan sheinberger
yochanan sheinberger - avatar
+ 1
MikeS can we see your code as we may be not totally grasping what you are asking. I believe yochanan sheinberger is actually giving you the correct answer.
29th Apr 2020, 10:19 PM
BroFar
BroFar - avatar
0
Maybe visibility:hidden?
29th Apr 2020, 9:45 PM
Abhay
Abhay - avatar
0
Farhan🇼🇳â˜Ș that's exactly what I am after however, how would I re-display it. Display:all; doesn't seem to work
29th Apr 2020, 9:52 PM
MBanski
MBanski - avatar
0
I managed to fix it by doing display: none and then display:inline to re-show it when wanted
30th Apr 2020, 11:05 AM
MBanski
MBanski - avatar
0
Yup we want code otherwise I really wrote how to use display:none and display:block but looks it's more complicated than what I think
30th Apr 2020, 11:19 AM
Abhay
Abhay - avatar
0
Display :none;
30th Apr 2020, 5:00 PM
Munguryek Innocent
Munguryek Innocent - avatar
0
Javascript: var f = document.getElementById("myForm"); f.addEventListener("onsubmit", function() { f.style.display = "none"; });
30th Apr 2020, 9:20 PM
Bartek Wilk
Bartek Wilk - avatar