如何在ace编辑器中更改背景图像?

时间:2017-04-23 12:09:21

标签: javascript html css editor ace-editor

我在 CSS 中尝试了这个,但它没有用。我还尝试了保存的照片  我的电脑

.ace_identifier{
 background-image : url("https://www.google.com.eg/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwji1duTxbrTAhUEOBQKHamBCvQQjRwIBw&url=https%3A%2F%2Fox-fest.org%2F2017%2F02%2F06%2Fupcoming-workshop-coding-with-morgan-stanley%2F&psig=AFQjCNECub5OZqaxX9R684Gm4HLX-X7Zdw&ust=1493035590367032");
}

.ace_identifier {  background-image:url(“https://s-media-cache-ak0.pinimg.com/564x/1c/da/05/1cda057bcd14d46c68e3051dc26f6850.jpg”); }

编辑: 我尝试了一个工作网址。问题

1 个答案:

答案 0 :(得分:3)

如果将css应用于正确的选择器,

css应该有效,并确保没有规则覆盖它。

<script src=http://ajaxorg.github.io/ace-builds/src-noconflict/ace.js></script>
<script>
var editor = ace.edit()
// set class to editor to use in css,
// could use .ace_editor too, but that
// would match all editors on the page
editor.container.classList.add("myEditor")
editor.setTheme("ace/theme/monokai")
editor.setValue("some text here", -1)
document.body.appendChild(editor.container)
</script>

<style>
.myEditor {
  position: fixed;
  left: 0; right: 0; bottom: 0; top: 0;  
  background :  url(https://s-media-cache-ak0.pinimg.com/564x/1c/da/05/1cda057bcd14d46c68e3051dc26f6850.jpg);
}
}

</style>