I am faced with a scenario where I have the following DOM structure:
<input type='text'>
<button>Add</button>
and this CSS styling:
button {
visibility: hidden;
}
input:focus + button {
visibility: visible;
}
In this setup, the button is only visible when the input element is focused. I have attached a click listener to the button, however, it does not seem to work as expected.
Upon further investigation, I discovered that adding a transition property to the button resolves the issue. Unfortunately, transitions are supported on IE10 and above.
button {
transition: visibility 1s ease;
}
My question now is: Is there an alternative CSS approach to achieve this behavior without relying on JavaScript's focus and blur events?