Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<textarea> with horizontal rule

Tags:

html

css

Does anyone know of a way to create horizontal rules within a <textarea> without using a background image?

CSS3 would be fine. I can bodge an image fallback for IE if necessary.

Example:

enter image description here

like image 292
Turnip Avatar asked Feb 27 '12 16:02

Turnip


3 Answers

You can do this using linear gradients:

.notes {
    background-attachment: local;
    background-image:
        linear-gradient(to right, white 10px, transparent 10px),
        linear-gradient(to left, white 10px, transparent 10px),
        repeating-linear-gradient(white, white 30px, #ccc 30px, #ccc 31px, white 31px);
    line-height: 31px;
    padding: 8px 10px;
}
<textarea class="notes"></textarea>

JSFiddle Version

like image 134
Ry- Avatar answered Oct 01 '22 03:10

Ry-


.notes {
    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;
}

.notes:focus {
    outline: none;
}

body {
    background-color: #eee;
}
<textarea class="notes"></textarea>
like image 43
nifCody Avatar answered Oct 01 '22 01:10

nifCody


I think that may be a background image. Look up on CSS background or background-image property then assign it the textarea in question.

like image 22
Script47 Avatar answered Oct 01 '22 01:10

Script47