The transition-duration appears to be ineffective when combined with the Boostrap .form-control class

I've been working on a Sign In registration box using HTML, CSS, and JS with the help of Bootstrap.

I added a simple animation where clicking a button makes the middle input field slide to the left while the top and bottom input fields move up and down, creating a closing and opening effect.

Initially, everything worked fine without any Bootstrap classes. But when I added the form-control class to the input field, the transition duration specified in the CSS (transition-duration: 0.5s;) seemed to stop working.

Here's a snippet of my code:

const menuBtn = document.querySelector('.button');
const repeatInput = document.querySelector('.new_pss');
const repeatInput_1 = document.querySelector('.user');
const repeatInput_2 = document.querySelector('.new_pss_rpt');
let menuOpen = false;
menuBtn.addEventListener('click', () => {
  if(!menuOpen) {
    repeatInput.classList.add('open');
    repeatInput_1.classList.add('open');
    repeatInput_2.classList.add('open');
    document.getElementsByClassName('new_pss_rpt')[0].placeholder='Password';
    menuOpen = true;
  } else {
    repeatInput.classList.remove('open');
    repeatInput_1.classList.remove('open');
    repeatInput_2.classList.remove('open');
    document.getElementsByClassName('new_pss_rpt')[0].placeholder='Repeat Password';
    menuOpen = false;
  }
});
html,
body {
  height: 100%;
}

body {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #f5f5f5;
}

.form-signin {
  width: 100%;
  max-width: 330px;
  padding: 15px;
  margin: auto;
}

.button{
  position:relative;
  margin-top: 10px;
}
.new_pss.form-control,
.user.form-control,
.new_pss_rpt.form-control{
  transition-duration: 0.5s;
}
.new_pss.form-control.open {
  transform: translateX(-300px);
  opacity: 0%;
}
.input{
  padding: 2px;
}
.user.form-control.open{
  transform: translateY(13px); 
}
.new_pss_rpt.form-control.open{
  transform: translateY(-13px); 
}
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">

<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>



<body class="text-center">
  <form class="form-signin">
    <div class="input">
      <input type="text" class="user form-control" placeholder="Username"></input>
    </div>
    <div class="input">
      <input type="text" class="new_pss form-control" placeholder="Password"></input>
    </div>
    <div class="input">
      <input type="text" class="new_pss_rpt form-control" placeholder="Repeat Password"></input>
    </div>
    <div class="btn">
      <button type='button' class="button">Sign In Test</button>
    </div>
  </form>

You can find the live version of this codehere.

Do you see what might be causing this issue?

Answer №1

When setting a duration, make sure to specify what you want to animate. In this case, adding transition-property: transform; is necessary. To animate all properties, use all, but for just transformation, it's enough. Alternatively, simplify with transition: all 0.5s;. (https://example.com)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Regular expressions used to efficiently parse CSS selectors

I am looking to enhance the scope of my selectors. One effective method, in my opinion, is to target a CSS selector and return a combination of mySelector and oldSelector For instance, if I have .old { background: black; }, I would modify it to .mySelecto ...

How to design an HTML table with columns of a set width using CSS

I need a table that has a fixed width but dynamic height to accommodate varying content lengths. Take a look at this example: Despite setting a fixed width, my content is overlapping. What am I doing incorrectly? Here is my current code: <table width= ...

Is it possible for me to overlap a text over hidden text, and if the hidden text becomes visible through JavaScript, my text will shift to the right of the now visible hidden text?

I'm currently working on a website for a company that requires users to complete all the information before proceeding. To achieve this, I created a form with the following code: <form action="Owners Infoback.php" onsubmit="return validateFo ...

Class is still visible after the media query preview is looked at, despite attempts

Our print preview library is set up to display the final product to users, but we don't want the images to actually be printed since we are using branded paper. To address this, I have included a print media query in the print.css file and added all ...

Form submission not capturing multiple HTML select options

I have encountered an issue with a form that contains 2 fields: a hidden field and a multiple select. Upon form submission, the hidden field successfully reaches the django views.py file, but the selected values from the multiple select do not get transmit ...

Retaining the value of a textbox while moving to another page

On a specific page (let's call it the sample page), there are four text boxes with pre-filled values. There is a button on this page for navigating to the next page, which also has a back button that takes you back to the sample page. However, when re ...

Using JavaScript to create a tree structure with hierarchical organization in JSON

Having some trouble converting a nested hierarchical tree from a JSON array. Looking to create a hierarchical tree structure from the provided JSON data. Below is the data: [{ "_id" : "59b65ee33af7a11a3e3486c2", "C_TITLE" : "Sweet and Snacks", ...

Determining the JavaScript event source within a function's scope: A guide

Query Can we determine the origin of a function being triggered by either a user event or an async event, without having access to the original event parameter? Situation I am faced with the challenge of identifying the event source within a nested funct ...

ReactJS Form: Updates in Parent Component State Result in Child Field Being Cleared and Props Remaining Unchanged

I have devised a ReactJS code for an interactive form that allows the collection of student details. The beauty of this form is that it can accommodate any number of students with ease. In this setup, the parent component is known as App and the child comp ...

What strategies can I implement in Angular to enhance the efficiency of my code and reduce load time? Presently, the load time stands at 2

I'm looking to enhance the performance of my code to increase speed. How can I optimize the following code snippet to further improve load time? Additionally, any suggestions on what considerations I should keep in mind would be greatly appreciated. C ...

Guide to creating animated sections using only CSS as you scroll the webpage

I am searching for a method to add animation effects (using @keyframes, transform...) to certain elements as the user scrolls down the page. For instance: When the offset is 0: the div will have a height of 100px. When the offset is between 0 and 100: th ...

What is the proper way to provide parameters for express.use to avoid encountering a type error?

When attempting to use the path string in this code snippet within the function, an error is thrown. The argument type string cannot be assigned to the parameter type RequestHandler<RouteParameters>    The assigned type does not contain call si ...

When I click on the button, the page reloads instead of executing the essential code

On my website, there is a settings page where users can edit their profiles. After editing, they click the update button which triggers the updateProfileData function. This works smoothly in Chrome browser, but in Firefox, the page reloads as soon as the b ...

Utilizing the calc() function to determine height dimensions

I created a very simple layout with 5 divs, which can be viewed here: http://jsfiddle.net/8tSk6/. In this layout, I want the div with the ID "kubka" to have a height of 100% - 100px (height: calc(100% - 100px);). However, I am running into issues as it i ...

Transferring a dynamic property from the $root instance to a child component through vue-router

How can VueJS pass a prop to a child component from the $root view instance while using vue-router? $root instance: const router = new VueRouter({ routes: [{ path: "/dashboard", component: () => import("./User/Dashboa ...

The jQuery .html() method cannot be used to replace a JavaScript chart

Utilizing jQuery's ajax calls to generate a Dojo toolkit chart based on the user's selection from a drop-down menu is proving tricky. The issue arises when attempting to replace the existing chart - instead of swapping it out, the new chart appea ...

Shifting an element to the opposite end of a container in Bootstrap 4

I've searched for a similar question that has been asked before but didn't find the exact same issue. I am attempting to shift the phone number from the left, where other elements are, to the far right of the container. I have tried various comma ...

Enabling Cross-Origin Resource Sharing (CORS) for Tomcat REST API

Recently, I set up a local Tomcat installation on port 8081 to expose a REST API. However, my development web server operates on port 9000. I want to make calls to the REST API from JavaScript code running in the browser using Angular's $http. Due to ...

Having issues with setInterval function when restricting the number of MySQL rows

My simple chat application with setInterval is experiencing an issue when I try to limit the number of rows displayed from the database. Currently, the chat loads everything from if($q == "load") { and functions correctly. However, when I attempt ...

Detecting when a user navigates backwards on a mobile device using JavaScript

I am currently working on a basic HTML file that includes a JavaScript code snippet: <p>Press The Back Button and see a message!</p> <script> window.onpopstate = function(event) { alert("location: " + document.location); } ...