加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – Textarea 100%宽度溢出父容器

发布时间:2020-12-14 16:37:21 所属栏目:资源 来源:网络整理
导读:如果宽度设置为100%,我遇到的问题是textarea(可能还有任何输入元素)显示得太宽.这是我的CSS. 首先,我正在重置所有样式. html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img
如果宽度设置为100%,我遇到的问题是textarea(可能还有任何输入元素)显示得太宽.这是我的CSS.

首先,我正在重置所有样式.

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,section {
    display: block;
}
body {
    line-height: 1;
}
ol,ul {
    list-style: none;
}
blockquote,q {
    quotes: none;
}
blockquote:before,blockquote:after,q:before,q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

然后将样式应用到我的表单.

form fieldset {
    border: none;
    border: 1px solid #ff0000;
    padding: 5px;
}
form fieldset legend {
    font-size: 20px;
    font-weight: bold;
}
form textarea {
    width: 100%;
    height: 500px;
}

最后是我的HTML.

<form method="post">
    <fieldset>
        <label for="area">Content</label>
        <textarea id="area" name="area"></textarea>
    </fieldset>
</form>

在Chrome和Firefox中(尚未测试其他版本),textarea在左侧正确填充5px,但在右侧textarea要么与字段集齐平,要么溢出一点.

有一件事是,如果我从页面中删除doctype,一切都会正确显示.

解决方法

重置textarea,我没有在你的重置CSS看到它.

可能它继承了一些利润.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读