简体   繁体   English

内联Textarea样式覆盖CSS默认

[英]Inline Textarea Style to override the CSS default

I need your help with the textarea of my form fields. 我需要您在我的表单字段的文本区域方面的帮助。 I have the CSS below to apply a general style for the texarea. 我在下面使用CSS为texarea应用常规样式。 But now i'll like to make some inline changes to some particular textarea because they are overlapping beyond the container. 但是现在我想对某些特定的textarea进行内联更改,因为它们重叠在容器之外。

Thanks for the help. 谢谢您的帮助。

    textarea[type=text]{
    border:             2px solid #a9c6c9;
    vertical-align:         middle;
    padding:             9px;
    height:             129px;
    border-collapse:         collapse;
    margin:             2px;
    padding:             2px;
    space:             2px;
    width:             6.1in;
    z-index:             1;
    font-family: calibri;
   }

You can use :not to filter out the ones you don't want to change. 您可以使用:not过滤掉您不想更改的内容。 Change your CSS selector to: 将您的CSS选择器更改为:

textarea[type=text]:not(#element1, #element2, ...)

If it's just a matter of ensuring nothing extends outside the container, try adding max-width:100%; 如果只是要确保没有任何东西延伸到容器之外,请尝试添加max-width:100%; to your textarea CSS. 到您的textarea CSS。 That should help you prevent it from going outside the container while still making all other textareas the same width. 这样可以帮助您防止其从容器中移出,同时仍使所有其他文本区域具有相同的宽度。

Try just adding a class to the individual textarea 尝试仅将一个类添加到各个文本区域

<!-- Original -->
textarea[type=text]{
    border: 2px solid #a9c6c9;
    vertical-align: middle;
    padding: 9px;
    height: 129px;
    border-collapse: collapse;
    margin: 2px;
    padding: 2px;
    space: 2px;
    width: 6.1in;
    z-index: 1;
    font-family: calibri;
}

then: 然后:

<!-- add this class to you individual textarea's -->
textarea[type=text].newclass{
    width: 200px;
}

or you can have it inside a div like so: 或者您可以将它放在div之内,如下所示:

<!-- add this class to the <div> your individual textareas are inside of -->
.newclass textarea[type=text]{
    width: 200px;
}

or add this to your textarea in you html: 或将其添加到html中的textarea中:

style="width:200px !important;"

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM