Javascript/Jquery 技术:使用溢出:隐藏对固定大小的文本区域进行分页
我有一个用户输入
#input_text{
height:200px;
overflow:hidden;
border-width:0;
background-color:transparent;
}
'overflow:hidden' 的主要原因是为了避免在文本区域已满。相反,我希望在文本区域变满时进行分页。实现这一点的最佳方法是什么?我正在考虑 javascript/jquery,但不确定具体如何。
附加说明:当到达文本区域末尾时,会自动进行分页(新页面),而如果用户退格或单击指向该页面的链接(返回到第 1 页),则页面会切换回来(旧页面)。
并不期待完整的解决方案,但一些有用的提示会对我(可能也是未来的编码员)派上用场。谢谢。
I have a user input <textarea id='input_text'>
element, with the following CSS:
#input_text{
height:200px;
overflow:hidden;
border-width:0;
background-color:transparent;
}
The main reason for 'overflow:hidden' is to avoid the ugly scroll bar that pops up when the textarea is full. Instead, I would like pagination to occur when the textarea becomes full. What would be the best way to implement this? I'm thinking javascript/jquery, but not sure exactly how.
Additional notes: When end of textarea is reached, pagination occurs automatically (new page), while the page switches back (old page) if the user backspaces, or clicks on a link to it (back to page 1).
Not expecting full solution, but some useful hints would come in handy for me (possibly future coders as well). Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会做类似的事情:
该解决方案的“有趣”部分是当中间添加或删除某些内容时如何重新流动页面。
I'd do something like:
The 'fun' part of this solution would be how to re-flow the pages when something is added or deleted in the middle.
文本区域分页是一个可怕的想法。如果我的评论太长,我不应该翻阅多个页面来阅读它。
我会选择 http://plugins.jquery.com/project/TextAreaResizer,同样StackOverFlow 在其文本区域上使用的插件。它允许用户根据自己的喜好扩展文本区域。
Pagination of a textarea is a horrible idea. If my comment is too long I shouldn't have to go through multiple pages to read it through.
I'd go with http://plugins.jquery.com/project/TextAreaResizer, the same plugin that StackOverFlow uses on its text areas. It allows the user to expand the textarea as he or she pleases.
jQuery.elastic 插件将满足您的需求。随着更多文本输入其中,它会垂直拉伸文本区域。
The jQuery.elastic plugin will do what you are looking for. It stretches the textarea vertically as more texts gets entered into it.