1

I am working on a site in which I have bunch of html and css code; now in css I have written for idle loading and have written some more css code which performs a animation or new css properties with help of transition!

but the twist is I want to add the new css animation code when a button is pressed (using js).

For e.g

       <div class="cover-details-signin cover-d" id="cover-signin">
          <h1 class="cover-heading">Welcome Back!</h1>
          <p class="cover-description">
            To keep connected with us please login with your personal info
          </p>
          <a href="#" id="cover-signin-btn auth-btn" class="cover-button"
            >SIGN IN</a
          >
        </div>
        <!-- cover -->
        <!-- cover -->
        <div class="cover"></div>

css


.cover {
  width: 26.2%;
  height: 80%;
  position: absolute;
  /*background-color: rgba(0, 0, 255, 0.281);
  */
  background: rgb(3, 185, 104);
  background: linear-gradient(
    47deg,
    rgba(3, 185, 104, 1) 0%,
    rgba(2, 163, 195, 1) 100%
  );
  transition: 1.5s ease-in-out;
  border-radius: 0.8em 0em 0em 0.8em;
  -webkit-border-radius: 0.8em 0em 0em 0.8em;
  -moz-border-radius: 0.8em 0em 0em 0.8em;
  -ms-border-radius: 0.8em 0em 0em 0.8em;
  -o-border-radius: 0.8em 0em 0em 0.8em;
  -webkit-transition: 1.5s ease-in-out;
  -moz-transition: 1.5s ease-in-out;
  -ms-transition: 1.5s ease-in-out;
  -o-transition: 1.5s ease-in-out;
}

.cover-details-signin {
  z-index: 5;
  min-width: 35% !important;
  height: 100%;
  display: flex;
  color: #ffffff;
  flex-direction: column;
  align-items: center;
  transform: translateX(0%);
  transform-origin: center;
  background-color: transparent;
  transition: 1.5s ease-in-out;
  font-family: "Montserrat", sans-serif;
  -webkit-transform: translateX(0%);
  -moz-transform: translateX(0%);
  -ms-transform: translateX(0%);
  -o-transform: translateX(0%);
  border-radius: 0.8em 0em 0em 0.8em;
  -webkit-border-radius: 0.8em 0em 0em 0.8em;
  -moz-border-radius: 0.8em 0em 0em 0.8em;
  -ms-border-radius: 0.8em 0em 0em 0.8em;
  -o-border-radius: 0.8em 0em 0em 0.8em;
  -webkit-transition: 1.5s ease-in-out;
  -moz-transition: 1.5s ease-in-out;
  -ms-transition: 1.5s ease-in-out;
  -o-transition: 1.5s ease-in-out;
}

.cover-details-signin .cover-heading {
  margin-top: 50%;
  font-size: 2.8em;
  font-weight: 700;
  font-family: "Montserrat", sans-serif !important;
}

.cover-details-signin .cover-description {
  width: 45%;
  margin-top: 1.84812535698526854688856em;
  text-align: center;
  font-size: 0.9em;
  line-height: 1.8em;
}

.cover-details-signin .cover-button {
  width: 30%;
  text-decoration: none;
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  border: 1px solid #ffffff;
  background-color: transparent;
  font-size: 0.8em;
  border-radius: 3em;
  margin-top: 3em;
  padding: 1.1em 0.5em 1.1em 0.5em;
  /* height: 3em; */
  -webkit-border-radius: 3em;
  -moz-border-radius: 3em;
  -ms-border-radius: 3em;
  -o-border-radius: 3em;
}

CSS code in the same file which I want to start/toggle on button click button with class .cover-signin-btn

.cover {
  border-radius: 0em 0.8em 0.8em 0em;
  transform: translateX(186.3%);
  -webkit-transform: translateX(186.3%);
  -moz-transform: translateX(186.3%);
  -ms-transform: translateX(186.3%);
  -o-transform: translateX(186.3%);
  -webkit-border-radius: 0em 0.8em 0.8em 0em;
  -moz-border-radius: 0em 0.8em 0.8em 0em;
  -ms-border-radius: 0em 0.8em 0.8em 0em;
  -o-border-radius: 0em 0.8em 0.8em 0em;
}

.cover-details-signin{
  /* invisible color */
  color: #e9e9e9 !important;

  /* value for invisible */
  transform: translateX(-200%);
  -webkit-transform: translateX(-200%);
  -moz-transform: translateX(-200%);
  -ms-transform: translateX(-200%);
  -o-transform: translateX(-200%);
}

.cover-details-signin .cover-button {
  /* invisible border */
  border: 1px solid #e9e9e9;
}

PLease help me, how to do it!!!

2
  • you will have to do it with jquery not js . Commented Apr 18, 2020 at 13:29
  • actually I also tried addClass toggleClass, .css() and much jQuery, but still it didn't worked! Commented Apr 18, 2020 at 14:18

1 Answer 1

1

If you want to animate onclick of class cover-button you must do it by

$('.cover-button').onclick(function(){
    $(....).animate({height : "100px"})
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.