Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Transition with Textarea's resize conflict

When I apply transition to textarea, it's by default affect the resize function of it. I want to disable transition only on the resize action of textarea, but not the textarea it self - is this even possible to do?

<textarea name="" id="" class="txtarea"></textarea>

.txtarea {
  transition: 3s;
  resize: vertical;
  height: 140px;
  max-height: 350px;
  min-height: 140px;
}

I'm not willing to disable transition entirely for the textarea, but only for the resize action

Would be very nice to have a CSS solution, but if not, JS will be OK as well.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can whitelist a set of transition properties you need, for example color, and simply omit height from that list (the default value for transition-property is all).

Notice in the snippet below how the color property transitions smoothly, while resizing happens instantly.

.txtarea {
  transition: color 3s;
  resize: vertical;
  height: 140px;
  max-height: 350px;
  min-height: 140px;
}

.txtarea:focus {
  color: #f00;
  font-size: 1.5em;
}
<textarea name="" id="" class="txtarea"></textarea>


If both events require the height property to change, you can dynamically adjust textarea.style.transitionProperty when you want to trigger the smooth change:

var textarea = document.querySelector('textarea')

var token

function reset (e) { e.style.transitionProperty = '' }

function setHeightSmooth (px) {
  clearTimeout(token)
  textarea.style.transitionProperty = 'all'
  textarea.style.height = px + 'px'
  token = setTimeout(reset, 3000, textarea)
}
.txtarea {
  transition: color 3s;
  resize: vertical;
  height: 140px;
  max-height: 350px;
  min-height: 140px;
}

.txtarea:focus {
  color: #f00;
}
<button onclick="setHeightSmooth(350)">Expand</button>
<button onclick="setHeightSmooth(140)">Collapse</button>
<br>
<textarea name="" id="" class="txtarea"></textarea>

over 4 years ago · Santiago Trujillo Report

0

Not entirely sure I understood the question correctly but my interpretation is that you want transition for everything except the height. Then a simple css solution is this:

.txtarea {
    transition: all 3s, height 0s;
}

I know its a bit late but maybe this will help someone with the same question.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!