Avoiding applying the Textarea Transition on Resize is crucial

Currently, I am working on a Reactjs contact page where I have implemented a focus effect and transition for the textarea. However, I am facing an issue - when I resize the textarea, the transition is also applied to it, which is not desired.

I have added the transition in textarea:focus, but it does not work when I unfocus on the textarea.

Snippet of Relevant Code

ContactPage.css

.container input, .container textarea {
    background-color: #00000009;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    outline: none;
    resize: vertical;
    padding: 0px; /* Ensures even padding on both sides */
    transition: 0.25s ease-in-out;
    width: 100%;
}

.container input:focus {
    border-bottom: 2px solid red;
}

.container textarea:focus {
    border-bottom: 2px solid red;
}

Answer №1

In the transition, you have the ability to specify which properties should be impacted.

.container input, .container textarea {
    background-color: #00000009;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    outline: none;
    resize: vertical;
    padding: 0px; 
    transition: border-bottom 0.25s ease-in-out; /* Only the border-bottom property will change with this specification. */
    width: 100%;
}

Answer №2

To avoid using transition: all and manually apply transitions to each item instead. Check out this link for a list of properties affected by transition: all: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties

The previous solution suggested using border-bottom, which may work in certain cases but additional transitions may be needed depending on your text area's styling. For example, I had to include the following transitions for my text area with dynamic color and background changes:

transition: border 100ms ease-in, background-color 100ms ease-in, box-shadow 100ms ease-in;

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

Enhancing Application Performance Through Next.js Development

I'm currently working on an application using next.js and I am looking to implement code splitting in order to reduce the bundle size and load pages on demand. Unfortunately, I have not been able to find a way to do this without specifying routes. Fo ...

Error: Headers already sent, please check the sequence of your Expressjs, Firebase, React, and Redux code

After spending hours researching, I stumbled upon an interesting issue. I am working on a small app using ExpressJS, Firebase, and React. My goal is to call the Firebase Database through the Express Backend and also make post requests to store data in the ...

Retrieve State from Store in Routing Configuration File [using react-router v4 and redux-thunk]

I'm currently in the process of creating a ReactJS web application (still learning the ropes). In my project, I am making use of react-router v4 and redux-thunk. I'm seeking guidance on how to retrieve the current state value from my store withi ...

Position 2 divs to the right, with one on top of the other

As I navigate through the challenges of using floats, I find myself back at square one. My goal is to have two divs of varying widths float to the right of my page. You can view the page I'm working on here: recipe page Any assistance in understandin ...

Maintain the line breaks within the <ExpansionPanelDetails> component in Material UI

When I expanded the panel, it appeared as follows: <ExpansionPanel> <ExpansionPanelSummary>this is a title</ExpansionPanelSummary> <ExpansionPanelDetails> <Typography>line 1</Typography> <Typogr ...

What is the best way to run tests on this method using Jest?

import { format, getDaysInMonth, getMonth, getYear, isValid, parse } from "date-fns"; export class DateService { public getDaysInMonth(month?: Date) { return getDaysInMonth(month || new Date()); } What is the best way to test this func ...

What is the best way to modify a newly added element using jQuery?

When a user clicks a button on my screen, a new template is loaded dynamically using jQuery's .load() method. This transition adds new HTML to the page that was not present when the script initially loaded: (function($) { $('.go').on("c ...

React rendering failure detected

<script> const container = ReactDOM.createRoot(document.getElementById('container')); container.render(<h1>Hello, world!</h1>); </script> <div id="container"> </div> When trying to run the above HTML snippet, ...

The React/Three.js project deployed on Vercel is experiencing performance issues, however, it runs smoothly when tested locally

Recently, I encountered an issue with my simple React project that utilizes Three.js to create a 3D scene. While testing it locally, everything worked perfectly with frame rates between 40-60 fps. However, when I decided to host it on Vercel, the performan ...

Segment the progress bar into sections

Struggling with an Angular app, and still new to HTML and CSS, I am attempting to create a unique progress bar. I aim to split each section of the progress bar into two subsections with distinct background colors shown in this image: https://i.sstatic.net/ ...

How can I use Angular 7 to create a background image for a View made up of multiple components?

Here is the HTML code that I am working with: <app-navbar></app-navbar> <router-outlet></router-outlet> My goal is to have an image set as the background for the home view, which consists of two components: navbarComponent and hom ...

Employ the CSS pseudo-element :before within a UL element to generate a vertical line

I'm currently working on a vertical menu with the capability of having submenus. My aim is to include a vertical line using CSS pseudo-element ::before along with border. The challenge I'm encountering is that the CSS is applying to the entire m ...

Can this PHP code be optimized for better efficiency?

Seeking to create dynamic links on a page where the link for the current page is excluded. The code functions as desired but seems repetitive - hoping for a more efficient solution, given limited programming experience. <div class= "links"> <?php ...

What is the best way to update my logo and incorporate a colored border at the bottom of my fixed header while the user is scrolling down?

After spending countless hours researching online, I've been struggling to implement header effects on scroll without using JavaScript. My goal is to achieve a simple effect where the header reduces in height, the logo changes, and a colored border is ...

Trouble shutting down the <DatePicker /> while within the <Dialog /> in MUI 5 and HeadlessUI

I am encountering an issue while using HeadlessUI with MUI 5. The problem arises when I attempt to close the date selection popper of the <DatePicker /> component inside a <Dialog /> component from HeadlessUI. Ideally, the popper should close u ...

Bootstrap 5's h-100 feature functions flawlessly in Chrome, however, it encounters issues when used with a group

Can you please refer to this question: Issue with Aspect Ratio of Images in Bootstrap 5 due to Padding After applying the h-100 solution, everything looks great on Chrome. Unfortunately, when I check it in Safari, the aspect ratio of the image gets distor ...

Troubleshooting peerDependencies issue in Laravel 9 while installing ReactJS and VueJS with laravel/ui

I added Laravel/Ui to a Fresh Laravel 9 installation for setting up ReactJs I followed these commands step by step in the command line interface: composer require laravel/ui php artisan ui react npm install After running the npm install command, I en ...

I have implemented the appropriate code to showcase a background color, yet it doesn't seem to be appearing on the screen. Additionally, I am utilizing Sass in this project

Could someone help me understand why the background color is not showing on my website? This is the CSS I am using html { font-size: 100%; -webkit-box-sizing: border-box; box-sizing: border-box; } *, *::before, *::after { -webkit-box-sizi ...

The React component was not able to receive any children as input

My Typescript-written React component is called GradientText.tsx: import React, { ReactNode } from "react" import { cn } from "@/lib/utils" const typeMap = { h1: "h1", h2: "h2", p: "p", } inte ...

As the page is scrolled upwards, the custom cursor's location shifts accordingly

In developing a custom hover cursor for my video div, I am encountering an issue where the cursor does not move with my mouse and remains in place when I scroll. Could someone please review my code and identify what I am doing wrong? Additionally, I have ...