how to hide a vertical scroll bar when not needed


I have a textarea which is contained in a div as I have jquery hint and wanted to use opacity without changing the border. There is a visible vertical scroll bar how I only want this displayed when I am typing in the text field and it goes beyond the container. I have tried overflow: auto; but does not work.


    <div id="name">
        <textarea name="message" type="text" id="message"
            title="Enter Message Here"
            rows=9 cols=60 maxlength="2000"></textarea>


#name { 
    border: 1px solid #c810ca;
    width: 270px;
    overflow: hidden; 
    position: relative;

#message {
    height: 400px;
    width: 235px;
    overflow: hidden;
    position: absolute;

This question is tagged with html css forms

~ Asked on 2012-03-05 00:39:45

The Best Answer is


overflow: auto (or overflow-y: auto) is the correct way to go.

The problem is that your text area is taller than your div. The div ends up cutting off the textbox, so even though it looks like it should start scrolling when the text is taller than 159px it won't start scrolling until the text is taller than 400px which is the height of the textbox.

Try this:

I set overflow:auto on the text box, and made the textbox the same size as the div.

Also I don't believe it's valid to have a div inside a label, the browser will render it, but it might cause some funky stuff to happen. Also your div isn't closed.

~ Answered on 2012-03-05 01:38:38


overflow: auto; or overflow: hidden; should do it I think.

~ Answered on 2012-03-05 00:41:56

Most Viewed Questions: