Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scroll 使用文本滚动的背景设置文本区域的样式?_Scroll_Textarea_Notepad - Fatal编程技术网

Scroll 使用文本滚动的背景设置文本区域的样式?

Scroll 使用文本滚动的背景设置文本区域的样式?,scroll,textarea,notepad,Scroll,Textarea,Notepad,我试图创建一个带有记事本背景的文本区域(如:),但在这个例子中,我遇到了同样的问题:当文本经过高度到达多行并且可以滚动时,背景不会随之滚动,因此,如果文本漂浮在所有行上,则看起来很糟糕。有没有办法让背景在文本滚动时随文本移动,看起来像是纸上的真实文字?我不知道是否有一种只使用CSS的方法。下面是一种使用jQuery的方法 它将背景y位置与滚动位置重新对齐 也许: <html> <head> <style> #fake_textarea{

我试图创建一个带有记事本背景的文本区域(如:),但在这个例子中,我遇到了同样的问题:当文本经过高度到达多行并且可以滚动时,背景不会随之滚动,因此,如果文本漂浮在所有行上,则看起来很糟糕。有没有办法让背景在文本滚动时随文本移动,看起来像是纸上的真实文字?

我不知道是否有一种只使用CSS的方法。下面是一种使用jQuery的方法

它将背景y位置与滚动位置重新对齐

也许:

<html>
  <head>
    <style>
      #fake_textarea{
        width:925px; 
        min-height:100%;
        background-repeat: repeat-y;
        background: url(http://www.artsinmotion.net/notebook_paper.jpg);
        padding-left:100px;
        font-family:arial;
      }

      #wrapper{
        width:1025px; 
        height:500px;
        overflow: auto;
      }
    </style>
  </head>
  <body>
    <div id='wrapper'>
      <div id='fake_textarea' contenteditable></div>
    </div>
  </body>
 </html>  

#假文本区{
宽度:925px;
最小高度:100%;
背景重复:重复-y;
背景:url(http://www.artsinmotion.net/notebook_paper.jpg);
左侧填充:100px;
字体系列:arial;
}
#包装纸{
宽度:1025px;
高度:500px;
溢出:自动;
}

谢谢Alcidesquireoz,成功了!但在Firefox中,文本似乎没有换行,而是在一行上继续,直到按Enter或Return键。我怎样才能把它送到wordwrap?