CSS-Selektor auf ein Element außerhalb des Label-Containers?
Gibt es eine Möglichkeit mit reinem CSS ein Element außerhalb eines input/label Containers anzusprechen?
<div>
<div class="labelcontainer">
<label for="toggle">Toggle</label>
<input type="checkbox" id="toggle" class="visually-hidden">
<div>
<div class="container2"></div>
</div>
Ich möchte, wenn das Label checked ist, das css von container2 ändern. Ich glaube aber, das geht nicht oder?
Unfortunately, there is no way to address an element outside the input/label container with pure CSS. This is because CSS can only be applied to elements within the hierarchical structure of the HTML document.
In this case, however, you could use JavaScript to achieve the desired behavior.
Thank you.
Sure, no problem.
Alex
No, I can’t. You need to use JS. This would then be the case (code not tested):
CSS
JS
Thank you.
I would recommend you for modifying JavaScript…is also quite easy and if it’s mostly just about css changes, this is hardly a problem for you.
DIe platform only allows HTML and CSS. That’s why pure CSS
Is it a platform for practicing or learning or what kind of one?
What you would like to do would be based on programming.
However, as you can’t program HTML and CSS, you need to try a programming language for your special requests.