So, trying to get some help om if/how this would be done.
I have a list of canvas elements on a page horizontally. I would like to have the behaviour that if I click on one of them, the OTHERS should get a width of 100px.
I’m in control of the click event on each canvas only, so I’m able to add a "selected" class on the canvas to be in focus. If no canvas have the selected class they should use their "default" value, but when selected is added, it does nothing to the canvas itself but finds all other canvases that doesn’t have the selected class and change their width.
2
Answers
So my solution is to use the CSS pseudo-class
:focus
.And to enable it to do so, you need to set
tabindex
for the canvas elements first.Here my example:
If the canvases have a common parent you can do this using the CSS :has (currently supported by major browsers except Firefox where the user has to set a flag to enable it) and CSS :not.