Your CSS selector is applying display: none
for a div.oculta
son of a .email:focus
. In its HTML, the div.oculta
will not be affected as it is not the son of .email:focus
.
That way, you could make it work: using the dial ~
or +
, that select elements followed:
.email:focus + div.oculta{
display:none;
}
<div class="form">
<input type="text" class="email" name="asdasd" placeholder="email" />
<div class="oculta">
teste
</div>
</div>
In case you want to hide the div.oculta
with HTML this way, it will not be possible to use CSS selectors to reach it from .email:focus
. Therefore, you will need a Javascript event onFocus
linked to the widget. For example:
document.querySelector('.email').onfocus = function() {
document.querySelector('.oculta').style.display = "none";
}
document.querySelector('.email').onfocusout = function() {
document.querySelector('.oculta').style.display = "block";
}
Thank you very much. I understand now. Yes it really works with js. I thank you
– Carlos da Silva