Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide scrollbar even if div is not larger then max-height

Tags:

html

css

i have a div named panel, CSS of whose is

enter image description here

.msg_panel
{
width:100px;
height:45px;
max-height:200px;
padding: 3px;
overflow-y:scroll;
overflow-x:hidden;
}

now even if height of panel is not larger than the max-height, i am getting the scrollbar visible(you can see in the pic). I want scrollbar visible only if max-height is attained.

i tried javascript, but can it be done only in css

like image 866
Zafta Avatar asked Jul 23 '13 08:07

Zafta


2 Answers

Set the overflow-y property to auto

Working Example http://jsfiddle.net/TLwcX/1/

like image 79
Kevin Bowersox Avatar answered Nov 13 '22 08:11

Kevin Bowersox


Set overflow-y to auto which removes the vertical scroll and it will appear only if the content exceeds your max-height of 200px...

.msg_panel
{
  overflow-y:auto;
}
like image 21
Arun Bertil Avatar answered Nov 13 '22 10:11

Arun Bertil