Looking for a way to display an element when an input field is selected without using JavaScript? Preferably, the solution should not involve placing the element within the input field. Unfortunately, targeting the element in CSS with the :active selector doesn't work as expected.
Currently, the structure is like this:
<div class="outer">
<input type="text" name="field" />
<div class="element"></div>
</div>
Is it possible to target a parent element after :active using the :root selector or something similar?
The existing CSS code:
.element {
display: none;
}
.outer:active .element {
display: block;
}
While this works, the element is only displayed when clicking and holding anywhere within the outer element, which is not ideal. I don't want to rely on :hover either. Open to suggestions!