Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format the scrollbar style on a textarea?

I'm sure this shouldn't be as difficult as it seems... I can't use a JQuery scrollpane because I need it to act as a standard form textarea when it gets submitted.. needs to work in IE7+, Safari & firefox at least... any ideas?

Tried this...

textarea {
    scrollbar-face-color: #ff8c00;
    scrollbar-track-color: #fff8dc;
    scrollbar-arrow-color: #ffffff;
    scrollbar-highlight-color: #fff8dc;
    scrollbar-shadow-color: #d2691e;
    scrollbar-3dlight-color: #ffebcd;
    scrollbar-darkshadow-color: #8b0000;
}

... but only works in IE ?

Any ideas??

like image 614
Chris Carruthers Avatar asked Aug 16 '11 13:08

Chris Carruthers


2 Answers

Use -webkit-scrollbar pseudo-elements for scroll bar:

textarea::-webkit-scrollbar {
    width: 1em;
}

textarea::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}

textarea::-webkit-scrollbar-thumb {
  background-color: darkgrey;
  outline: 1px solid slategrey;
}

You can find more detail here: https://css-tricks.com/almanac/properties/s/scrollbar/

like image 76
Huy Nguyen Avatar answered Nov 12 '22 05:11

Huy Nguyen


I have never done this so im not completely sure on this, but I remember one my colleagues was doing this for a site we were developing and he had the same minor issue.

I think you are along the right track, although the scrollbar properties need to be in the body css like so:

body {
 scrollbar-face-color: #ff8c00;
    scrollbar-track-color: #fff8dc;
    scrollbar-arrow-color: #ffffff;
    scrollbar-highlight-color: #fff8dc;
    scrollbar-shadow-color: #d2691e;
    scrollbar-3dlight-color: #ffebcd;
    scrollbar-darkshadow-color: #8b0000;
}

Maybe you could try giving the desired text area and id property and apply that in the css, so:

textarea.(insertrelevantID) {
.....
}
like image 29
RSM Avatar answered Nov 12 '22 07:11

RSM