如何限制jquery中工具提示的边界?

时间:2017-06-08 22:09:48

标签: jquery css

您好我正在使用带有codemirror的工具提示,我想要的是使工具提示的边框不在编辑器的边框之外...请参阅此链接以显示工具提示的边框如何超出编辑器的边框jsbin

这是代码: 的CSS:

.tooltip{background:red;z-index:1000;}

脚本:

var cm = CodeMirror(document.getElementById("editor"), {
    value: "function myScript() {\n    return 100;\n}",
    mode: "javascript",
    indentUnit: 4,
    lineNumbers: true,

});

var textMarker;

$('#add').click(function() {
    textMarker = cm.markText({
        line: 1,
        ch: 4
    }, {
        line: 1,
        ch: 10
    }, {
        className: 'marked-text'
    });

    $('.marked-text').tooltip({
        title: 'This is a return statement sfdl glrflg rgmlf',
        container: 'body',
        delay: { "show": 500, "hide": 100 },
        animation: false
    });
});

$('#remove').click(function() {
    if (textMarker) {
        textMarker.clear();
    }
});

我如何解决这个问题?

注意:我想要工具提示的标题,所以panding 0无法解决问题

1 个答案:

答案 0 :(得分:0)

我在你的css代码中添加了0填充。

html, body {
  padding: 0;
}

this你想达到什么目标?