[英]How can I change the color of selected text?
我需要使用 codemirror 更改所選文本的背景顏色。 任何人都可以幫忙嗎?
上面的答案缺少必要的!important
。 你需要:
.CodeMirror-selected {background-color: #CCCCCC !important;}
如果您還需要更改選擇前景色,CodeMirror 有mark-selection.js
插件來實現這一點。
更改 .CodeMirror-selected {} 的背景顏色,該類位於 codemirror.css
.CodeMirror-selected {background:#CCCCCC;}
我能夠通過覆蓋特定於 CodeMirror 主題的高亮顏色來解決這個問題:
/** OVERRIDE SELECTED TEXT HIGHLIGHT COLOR FOR THEMES: **/
/* isotope theme */
.cm-s-isotope div.CodeMirror-selected {
background: #0004FF !important;
}
/* colorforth theme */
.cm-s-colorforth div.CodeMirror-selected {
background: #0004FF !important;
}
/* 3024-night theme */
.cm-s-3024-night div.CodeMirror-selected {
background: #0004FF !important;
}
/** - - - - - **/
此解決方案適用於 CodeMirror 的 AngularJS 版本。
您需要導入mark-selection
添加並設置自定義背景顏色。
background-color: highlight;
我相信這是一個 CSS 問題。 請參考以下文章:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.