Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:42:12+00:00 2026-06-18T10:42:12+00:00

http://jsfiddle.net/Calum/5dqwJ/ CSS: textarea { height: 20px; margin: 20px; width: 585px; resize: none; overflow: hidden;

  • 0

http://jsfiddle.net/Calum/5dqwJ/

CSS:

 textarea {
        height: 20px;
        margin: 20px;
        width: 585px;
        resize: none;
        overflow: hidden;
        vertical-align: top;
        transition: height 3s;
        -webkit-transition: height 3s;
        -moz-transition: height 3s;
        -o-transition: height 3s;
    }

Javascript:

 $(document).ready(function () {

     $("textarea").focus(function (event) {
         if ($(this).val().length === 0) {
             $(this).height(100);
             $(this).css('resize', 'vertical');
             $(this).attr('placeholder', null);
         }
     });


     $("textarea").blur(function (event) {
         if ($(this).val().length === 0) {
             $(this).height(20);
             $(this).attr('placeholder', "Enter comment");
             $(this).css('resize', 'none');
         }
     });

 });

HTML:

<textarea placeholder='Enter comment'></textarea>

In Chrome, IE and Opera, when you focus on the textarea it expands and contracts with the CSS3 transition.

When I do the same with FireFox, it doesn’t animate anything.

Any ideas why?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:42:14+00:00Added an answer on June 18, 2026 at 10:42 am

    If you add the required attribute on your textarea, you could use the :invalid pseudo-class to target an empty textarea:

    textarea {
        height: 100px;
        margin: 20px;
        width: 585px;
        resize: vertical;
        overflow: hidden;
        vertical-align: top;
        -webkit-transition: height .3s;
        -moz-transition: height .3s;
        -o-transition: height .3s;
        transition: height .3s;    
    }
    
    textarea:invalid{  /* single line*/
        height: 20px;
        resize: none;
    }
    
    textarea:focus{
        height: 100px;
        resize: vertical;
    }
    

    demo

    (add box-shadow: none; if you don’t want the red border around it)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/2N854/ html: <img alt=test width=100 height=100> javascript: alert($('img').height()); On most browsers (chrome), the alert
http://jsfiddle.net/NykbP/ I am trying to make my margin-bottom css properties on .header , .mainBanner
http://jsfiddle.net/ianhk/t9Hj6/ <div style=width:250px; height: 100px; border: black solid 1px; overflow:auto> <table style=height:200px; border: red
http://jsfiddle.net/D6be5/ HTML <table class=example border=1> <tr> <td> <label>Enter text</label> <textarea>Enter text</textarea> </td> </tr> <tr
http://jsfiddle.net/w9E4K/7/ <div id=parent> <div id=left>Left</div> <div id=right>Right</div> </div>​ #left { display: inline-block; width: 75%;
http://jsfiddle.net/ZAvDd/ As my table row grows in height, I'd like my div inside to
http://jsfiddle.net/RpCTx/4/ The table columns aren't changing to the width I specified. The second column
http://jsfiddle.net/michelpm/jywqh/ The table has 1000 pixels of width, so the table columns with 3.9%,
http://jsfiddle.net/gfuKS/5/ var transitionInitial = {property: none}; var rules = [color, background-color]; var transitions =
http://jsfiddle.net/Greg_J/R5ZHk/ I'm appending a div to a container and then animating the height. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.