Style is also a label (supported in non-ie kernel browsers). When we set the style to contenteditable, the content can be edited. After careful experience, if we change the background to red. As long as the writing is complete, it will be presented immediately. Wow, it's very convenient for us to write that kind of dynamic editor effect in the future. If you have time
The code is as follows: |
Copy code |
<! Doctype html> <Html> <Head> <Meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <Title> </title> <Style type = "text/css"> Body style { Display: block; Background: #333; Color: white; Font: 13px/1.8 monaco, mono-space; Padding: 20px; White-space: pre; Margin: 0 auto; Width: 500px; Height: 100px; } </Style> </Head> <Body> <Style contenteditable> body {background: green ;}</style> </Body> </Html> |
For more information, visit here.
This document uses a div instead of a body. The code is as follows:
The code is as follows: |
Copy code |
<Style type = "text/css"> . Test_div style { Display: block; Background: #333; Color: white; Font: 14px/1.8 courier new; Padding: 20px; White-space: pre; Margin: 0 auto; Width: 250px; Height: 100px; } </Style> <Div class = "test_div"> <style contenteditable>. test_div {background: green ;}</style> </div> Have fun. |