Add lines to HTML texarea

It is possible to add lines to html textarea. When I say lines, I mean something like lines in a paper notebook. Something like that:






+3


source to share


2 answers


You can use the following:

HTML:

<textarea class="paperlines"></textarea>

      

CSS:

.paperlines
{
    background-image: -webkit-linear-gradient(left, white 10px, transparent 10px), -webkit-linear-gradient(right, white 10px, transparent 10px), -webkit-linear-gradient(white 30px, #ccc 30px, #ccc 31px, white 31px);
    background-image: -moz-linear-gradient(left, white 10px, transparent 10px), -moz-linear-gradient(right, white 10px, transparent 10px), -moz-linear-gradient(white 30px, #ccc 30px, #ccc 31px, white 31px);
    background-image: -ms-linear-gradient(left, white 10px, transparent 10px), -ms-linear-gradient(right, white 10px, transparent 10px), -ms-linear-gradient(white 30px, #ccc 30px, #ccc 31px, white 31px);
    background-image: -o-linear-gradient(left, white 10px, transparent 10px), -o-linear-gradient(right, white 10px, transparent 10px), -o-linear-gradient(white 30px, #ccc 30px, #ccc 31px, white 31px);
    background-image: linear-gradient(left, white 10px, transparent 10px), linear-gradient(right, white 10px, transparent 10px), linear-gradient(white 30px, #ccc 30px, #ccc 31px, white 31px);
    background-size: 100% 100%, 100% 100%, 100% 31px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 31px;
    font-family: Arial, Helvetica, Sans-serif;
    padding: 8px;
    width:300px;
    height:500px;
}
.paperlines:focus
{
    outline: none;
}

      

Jsfiddle example: http://jsfiddle.net/jagmitg/7kteksez/




EDITED: Added another example of a better scrolling method

Add the following to the class paperlines

http://jsfiddle.net/jagmitg/7kteksez/1/

background-attachment: local;

      

+6


source


Create an image like one line using some basic image tools and add it like background

in a text area

Add CSS:

textarea {
 background: url('path of image') repeat-y;
}

      



Note. Make the image the same height as the font you are going to use in the text area.

Hope it helps

0


source







All Articles