現(xiàn)在很多網(wǎng)站比如知乎的評(píng)論功能都是用div而不是textarea。但如果我按照下面這樣做的話,會(huì)存在鼠標(biāo)不會(huì)像真正的placeholder那樣和文字對(duì)齊的情況。請(qǐng)問知乎是怎么實(shí)現(xiàn)的,怎樣避免出現(xiàn)我這種情況?Stackoverflow上面一個(gè)類似的問題,line-height:normal也解決不了問題<!DOCTYPE html><html><head> <meta charset="utf-8"> <style> div { width:600px; border: 1px solid red; // line-height: normal; line-height: 200%; padding-left: 5px; } div:empty:before { content: attr(placeholder); display: block; color: #999; } </style></head><body> <div contenteditable="true" placeholder="輸入用戶名"></div></body></html>
關(guān)于用div實(shí)現(xiàn)的placeholder的不足?
心有法竹
2018-09-14 13:12:08