Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the color of selected text?

I need to change the background color of the selected text using codemirror. Can anyone help?

like image 368
user1159517 Avatar asked Sep 09 '12 13:09

user1159517


People also ask

How do you change the background color of certain text in word?

Add or change the background colorGo to Design > Page Color. Choose the color you want under Theme Colors or Standard Colors. If you don't see the color you want, select More Colors, and then choose a color from the Colors box.

What is the color of selected text?

When you select text in a webpage, the background gets a default blue color.

How do you change the color of one text in HTML?

<FONT COLOR= > To change some of the text in the HTML document to another color use the FONT COLOR Tag. To change the color of the font to red add the following attribute to the code to the <FONT COLOR=" "> tag. #ff0000 is the color code for red.


2 Answers

The above answer is missing the essential !important. You need:

.CodeMirror-selected {background-color: #CCCCCC !important;}

If you need to also change the selection foreground color, CodeMirror has the mark-selection.js addon to achieve that.

like image 56
kofifus Avatar answered Nov 05 '22 15:11

kofifus


Change the background color for .CodeMirror-selected {} , the class is located in codemirror.css

.CodeMirror-selected {background:#CCCCCC;}
like image 31
aljordan82 Avatar answered Nov 05 '22 16:11

aljordan82