CSS Opacity Transition not Working on Adding Class
15:52 15 Oct 2020

I a problem doing a simple CSS opacity transition on the selector #loginForm > div:first-child h1 by simply adding the class .animated to that element using JavaScript. Although it is not working. Below is the code:

document.querySelector('#loginForm > div:nth-child(2)').style.display = 'none';
document.querySelector('#loginForm > div:first-child').style.display = 'block';
var verified_text = document.querySelector('#loginForm > div:first-child h1');
verified_text.classList.add('animated');
#loginForm {
  position: relative;
  padding: 40px;
  background-color: #fcde84;
  border-radius: 5px;
  margin-top: 75px;
  width: 462px;
}

#loginForm>div:first-child {
  height: 380px;
  border: 0;
  filter: drop-shadow( 5px 8px 8px rgba(0, 0, 0, 0.1));
}

#loginForm>div:first-child div {
  margin-top: 165px;
}

#loginForm>div div {
  width: 150px;
  height: 150px;
  margin: 0 auto;
  overflow: hidden;
}

#loginForm>div:first-child h1 {
  font-family: 'Arial Rounded MT';
  color: rgb(109, 204, 91);
  text-align: center;
  display: block;
  transition: all 5s ease-out;
  opacity: 0;
}

#loginForm>div:first-child h1.animated {
  opacity: 1;
}

#loginForm h2 {
  font-size: 34px;
  text-transform: uppercase;
  line-height: 24px;
  color: #2f4e71;
  letter-spacing: -2px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}

#loginForm p {
  font-size: 17px;
  line-height: 40px;
  color: #333850;
  display: block;
  margin: 0 0 10px;
  font-weight: 700;
}

#loginForm>div:nth-child(2) div {
  border-radius: 50%;
  border: solid 2.5px #3A5E77;
}

#loginForm ul {
  padding: 10px 15px 10px 30px;
  background-color: #fc7f77;
  color: white;
  border-radius: 7.5px;
  margin: 12px 0;
  display: none;
}

#loginForm li {
  text-align: center;
  display: block;
  font-size: 24px;
}

#loginForm label {
  margin: 0 0 12px;
  display: block;
  font-size: 1.25em;
  color: #217093;
  font-weight: 700;
}

#loginForm input {
  border-radius: 32.5px;
  height: 65px;
  width: 100%;
  font-weight: 600;
  font-size: 1.55em;
  transition: box-shadow .2s linear, border-color .25s ease-out, background-color .2s ease-out;
}

#email,
#password {
  margin: 0 0 24px;
  padding: 0 1em 0;
  background-color: #f3fafd;
  border: solid 2px #217093;
}

#email:focus,
#password:focus {
  outline: none;
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
  border: solid 2px #4eb8dd;
}

#loginForm input[type="submit"] {
  padding: .65em 1em 1em;
  background-color: #4eb8dd;
  color: #FFF;
}

#loginForm input[type="submit"]:hover {
  background-color: #217093;
}

Verified

Join our community

Login to get instant access to our video courses

SVG goes here

    video of the problem: https://youtu.be/OGZWfBaG_aM

    I want the word verified to fade in

    javascript html css web-frontend