Hello, let’s say you have a simple grid: it has a header, a footer, and in the middle it has 3 columns. Also, you have a button that toggles the visibility of the rightmost column
Yes, I mean css selectors, Ideally, something in the likes of nth-child(3) to reference the 3rd column and be able to set its display property at will.
No, it’s not a prerequisite. I just wrote the code that way for simplicity’s sake.
3.AFAIK, Nothing wrong. It’s just I am more of a backend dev, so I am not sure if changing the gridTemplateColumns property for this use case is a good practice or a hack. In the past, when faced with use cases that require hiding things, I am accustomed to use selectors to get the element and then set its display to none.
I suggest you follow the examples in the codepens above and just use css to control everything. The js can just toggle a class and then the css can do all the rest. I dislike JS writing inline styles as that just complicates everything.
In the above Grid codepen I just added a class of hide to the page-wrap and then used css to hide the columne and change the spanning of the middle column.
I would avoid nth-child unless you absolutely know that the html will never change. It only takes a co-worker to add another column and not realise you have scripts or css targeting the nth item. Much better to have a class on the element to start with and then you can’t go wrong.
I believe the examples above have all you need to get this working now