<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Div+placeholder</title> <style> .rich{ color:balck; width:100px; height:100px; border: 1px solid red; margin: 20px 50%; } /*爲空時顯示 element attribute content*/ .rich:empty:before{ content: attr(placeholder); /* element attribute*/ /*content: 'this is content';*/ color:#red; } /*焦點時內容爲空*/ .rich:focus:before{ content:none; } </style> </head> <body> <div class='rich' contenteditable="true" placeholder='當 element 內容爲空時,我就會出現'></div> </body> </html>