How do I fix inconsistent Textarea bottom margin in Firefox and Chrome?

眉间皱痕 提交于 2019-11-27 01:27:57

问题


I'm trying to eliminate the extra bottom margin that both FF and Chrome seem to give to Textareas. Surprisingly IE seems to do it correctly. I would like to avoid using conditional includes but CSS3 tweaks are OK.

Sample Code

.red-box {
    background-color: red;
    overflow: hidden;
}
textarea {
    border: solid 1px #ddd;
    margin: 0px; /* Has no effect */
}
<div class="red-box">
    <textarea>No Margin Please!</textarea>
</div>

回答1:


By default, I believe both Chrome and Firefox will set these elements as display: inline-block;. Set display: block in your styles and you should be all set.




回答2:


If you want to leave it inline, simply try

vertical-align: top



回答3:


Set display: block for your textarea.




回答4:


Just disable resize as follow

textarea{resize: none;}



来源:https://stackoverflow.com/questions/3453959/how-do-i-fix-inconsistent-textarea-bottom-margin-in-firefox-and-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!