CSS线性渐变不滚动内容

时间:2014-05-28 07:13:03

标签: css background-image linear-gradients

问题

我有一个textarea,它使用线性渐变作为背景图像。我试图模仿一张衬纸#34;影响。我已将font-sizeline-height设置为获取行与文本之间的正确间距;

Lined paper textarea with correct margins

然而,一旦我向下滚动textarea,我发现了一个问题:

Lined paper textarea with messed up text and lines

即,我的背景图像不会随文本滚动。我尝试了background-attachment: scrollbackground-attachment: fixedbackground-attachment: local,但都没有解决我的问题。

CSS

textarea {
    height: 200px;
    font-size: 20px;
    line-height: 1;
    background-image: repeating-linear-gradient(to bottom,
                                                #fff,
                                                #fff 9.5%,
                                                #000 9.5%,
                                                #000 10%);
}

Fiddle

1 个答案:

答案 0 :(得分:0)

background-attachment: local实际 工作;只是不在我测试的Firefox中。