javascript - JQuery Lined TextArea 调整大小问题

标签 javascript jquery html css textarea

好的,这是我的问题:

  • 我正在使用 JQuery Lined TextArea plugin
  • 我希望文本区域覆盖所有浏览器窗口区域(全宽、全高)
  • 我希望即使在调整浏览器窗口大小时行号也能传播。

这是我的 HTML :

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
        <script src="jquery.min.js"></script>
        <script src="jquery-linedtextarea.js"></script>
    </head>
    <body>
        <textarea id="tv">
            Some sample text
        </textarea>

        <script>
            $(function() {
                $("#tv").linedtextarea();
            });
        </script>
    </body>
</html>

这是我的 CSS :

body
{
    margin:0;
    padding:0;
}

*:focus {outline:0px none transparent;}

textarea
{
    border:0;
    margin:0;
    width:100%;
    height:100%;
    font-family:Courier, "Courier New";
    font-size:12px;
}

/* Following lines taken directly from Demo */

.linedwrap {
    border: 1px solid #c0c0c0;
}

.linedtextarea {
    padding: 0px;
    margin: 0px;
}

.linedtextarea textarea, .linedwrap .codelines .lineno {
    font-size: 10pt;
    font-family: monospace;
    line-height: normal !important;
}

.linedtextarea textarea {
    padding-right:0.3em;
    padding-top:0.3em;
    border: 0;
}

.linedwrap .lines {
    margin-top: 0px;
    width: 50px;
    float: left;
    overflow: hidden;
    border-right: 1px solid #c0c0c0;
    margin-right: 10px;
    background:#DDD;
}

.linedwrap .codelines {
    padding-top: 5px;
}

.linedwrap .codelines .lineno {
    color:#AAAAAA;
    padding-right: 0.5em;
    padding-top: 0.0em;
    text-align: right;
    white-space: nowrap;
}

.linedwrap .codelines .lineselect {
    color: red;
}

有什么想法吗?

最佳答案

在您的文件中尝试此 jquery 代码:

<script>
    $(function() {
    $("#tv").width(window.screen.width);//widht of parent element of textarea
    $("#tv").height(window.screen.height);//height of parent element of textarea
        $("#tv").linedtextarea(
        {selectedLine: 1}
    );
    });
</script>

关于javascript - JQuery Lined TextArea 调整大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14771257/

相关文章:

jquery - DataTables 无法显示 Ajax 数据

javascript - 显示内联 block 不在同一行中显示 div

javascript - 将鼠标悬停在没有包装器的样式组件上

javascript - React Router Dom 不渲染任何组件

jquery - 在哪里可以获得更多 jQuery UI 主题?

html - 定时显示(仅限 CSS)——我们可以将持续时间作为 HTML 的一部分传递吗?

javascript - 通过 Ratchet v2.0.2 加载外部 map 脚本

javascript - 能检测到 "Show Insecure Content"浏览器提示吗?

javascript - Angular/Node 验证用户

javascript - Bootstrap 表导出和分页问题