【问题标题】:CodeMirror styles are not working after decorating the textarea装饰 textarea 后 CodeMirror 样式不起作用
【发布时间】:2021-10-05 06:38:36
【问题描述】:

我有一个Nuxtjs/Vuejs 应用程序,其中我有一个与XML/JSON 相关的textarea。在用户为这些textarea 提供值后,它们将使用CodeMirror 装饰成XML/JSON

最初,textarea 的高度为78vh,我希望我的CodeMirror 在进行美化后具有相同的height and width,并包含horizontal/vertical scroll bar 以在内容超出边界时移动.

我尝试像这样添加 CSS 属性,但它根本不起作用,我在浏览器中看到巨大的滚动条,而不是在 textarea 内。

.CodeMirror{
    height: 78vh;
    position: relative;
    overflow: hidden;
    border: 1px solid black;
}

我还尝试添加 !importantdiv > div > div > div > div.CodeMirror { 以确保我将父母考虑在内,但似乎没有什么对我有用。

谁能让我知道我需要做什么才能让我的textarea 拥有相同的height and width 并在其自身中包含horizontal and vertical scrollbar

我在CodeSandBox here中添加了我的示例代码:https://codesandbox.io/s/boring-water-g14zd?file=/pages/index.vue

【问题讨论】:

    标签: javascript html css vue.js codemirror


    【解决方案1】:

    我在 JS 中而不是在 CSS 中添加,这对我有用:

    for (const s of document.getElementsByClassName('CodeMirror')) {
            s.style.border = '1px solid black'
          }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      • 2011-12-28
      相关资源
      最近更新 更多