表單元素默認不繼承樣式

難題

  • 可能有人已經注意到了,有時button或者input是不會默認繼承樣式的,尤爲是font,直觀就能看出來了。

緣由

根據SO的回答,由於瀏覽器會採用系統默認的樣式來渲染大部分的表單元素,並且這個默認的樣式文件還能找到。想深刻了解的能夠戳下方參考文檔連接。css

方案

主動加上inherit,並非什麼好方案,可是也沒找到更好的。瀏覽器

.form-element {
    font:inherit;
}

參考文檔:
Why textarea and textfield not taking font-family and font-size from body?
Font-family is not inherited to the form input fields?code

相關文章
相關標籤/搜索