Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contenteditable--change background color when editing

When editing an element with the contenteditable attribute I want the background color of that element to change colors. For example, if the element background color was dark grey I would want it to turn white while editing the element and then reset back to dark grey when done editing.

like image 951
Sunday1290 Avatar asked Aug 01 '13 21:08

Sunday1290


1 Answers

You can use this CSS:

[contenteditable="true"] {
    background-color: grey;
}

[contenteditable="true"]:focus {
    background-color: white;
}

Here's the JSFiddle.

like image 82
user1234 Avatar answered Sep 26 '22 17:09

user1234