简体   繁体   English

HTML Textarea永久边框颜色

[英]HTML Textarea permanent border color

I have been trying to set the color of my textarea PERMANENTLY (not on focus) to a certain color.. And it does not work... I am using bootstrap( i dont know if it might have to do with this) but for some reason i cant set PERMANENTLY the border color of my textarea.. I have this in my CSS (and I have tried other combinations I have seen Stack overflow) but it does not work. 我一直在尝试将我的textarea的颜色永久(不聚焦)设置为某种颜色。并且它不起作用...我正在使用bootstrap(我不知道是否可能与此有关),但是对于由于某些原因,我无法永久设置我的textarea的边框颜色。我在CSS中有此设置(并且我尝试了其他已见过Stack Overflow的组合),但是它不起作用。

textarea{ 


  width: 650px; 
  min-width:650px; 
  max-width:650px; 

  height:400; 
  min-height:400px;  
  max-height:400px;

  border-color: red;                 /*NOT WORKING*/

}

Width and height works so dont worry about that. 宽度和高度有效,因此不必担心。

My textarea in the html looks like this: 我在html中的textarea看起来像这样:

<table class="table">
    <tr>
    <td><textarea id="task1" class="form-control"></textarea>
    </td>
</tr>

Yes, it is inside a table in which I have several textareas but still (Dont know if thats the reason, i dont think so).. 是的,它在一个表中,其中有几个文本区域,但仍然存在(不知道是否是这个原因,我不这么认为)。

Thanks! 谢谢!

Kevin 凯文

Beware you have a class .form-control that define the border, set !important to your textarea or add one more class and in your css and place your rules of that class after where the .fom-control is. 请注意,有一类.form-control定义了边框,将!important设置为textarea或在CSS中添加了另一个类,并将该类的规则放置在.fom-control

OPTION 1 选项1

CSS 的CSS

textarea{ 
  width: 650px; 
  min-width:650px; 
  max-width:650px; 
  height:400; 
  min-height:400px;  
  max-height:400px;
  border:solid 1px orange !important;    
}

OPTION 2 选项2

HTML 的HTML

<table class="table">
    <tr>
    <td><textarea id="task1" class="form-control orange-border"></textarea>
    </td>
</tr>

CSS 的CSS

.form-control {
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    color: #555;
    display: block;
    font-size: 14px;
    height: 34px;
    line-height: 1.42857;
    padding: 6px 12px;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    width: 100%;
}

.orange-border{ 
border:solid 1px orange;
}

DEMO HERE 此处演示

You need to set: 您需要设置:

border: 1px solid red;

or 要么

border-width: 1px;
border-color: red;
border-style: solid;

Ok this was a simple fix... I targetted by ID.. I said: 好的,这是一个简单的解决方法...我以ID为目标。

#task1{
border-color:red;
}

and it worked! 而且有效!

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

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