html - 不同页面上的不同文本区域元素

标签 html css

我想在不同的页面上放置不同的textareatextareaCSS 似乎覆盖了 rowscols 我尝试为第二个 文本区域。我试过“textarea”和“textarea1”,但这显然不起作用。

textarea {
  width: 40%;
  height: 75px;
  padding: 12px 20px ;
  box-sizing: border-box;
  border: 5px solid #D8FF01;
  border-radius: 4px;
  background-color: #000;
  color: white;
  font-weight: bolder; 
  resize: both;
}
<form>
  <textarea name="comment" placeholder="Enter text here"></textarea>
</form>

<form>    
  <textarea name="reason" placeholder="Enter text here: (500 characters maximum)" maxlength="500" rows="10" cols="50"></textarea>
</form>

最佳答案

你可以这样使用

textarea:not(.reason) {
    width: 40%;
    height: 75px;
    padding: 12px 20px ;
    box-sizing: border-box;
    border: 5px solid #D8FF01;
    border-radius: 4px;
    background-color: #000;
    color: white;
    font-weight:bolder; 
    resize:both;
}
<form>
<textarea name="comment" placeholder="Enter text here"></textarea>
</form>

<form>    
<textarea name="reason" class="reason" placeholder="Enter text here: (500 characters maximum)" maxlength="500" rows="10" cols="50"></textarea>
</form>

这样,CSS选择器就使用了元素的class

textarea.myTextBox {
  width: 40%;
  height: 75px;
  padding: 12px 20px;
  box-sizing: border-box;
  border: 5px solid #D8FF01;
  border-radius: 4px;
  background-color: #000;
  color: white;
  font-weight: bolder;
  resize: both;
}
<form>
  <textarea name="comment" class="myTextBox" placeholder="Enter text here"></textarea>
</form>

<form>
  <textarea name="reason" placeholder="Enter text here: (500 characters maximum)" maxlength="500" rows="10" cols="50"></textarea>
</form>

关于html - 不同页面上的不同文本区域元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49826455/

相关文章:

html - 我应该在哪里清理以使花车工作?

javascript - Bootstrap 3 Collapse - 基于折叠状态的链接图标

html - 如何在 Safari 浏览器上不使用 CSS 不在 HTML <details> 中显示箭头

LI 中的 HTML CSS 垂直对齐

css - 在 2 列中堆叠可变高度的 div,例如 Facebook 时间轴

javascript - 使用 jquery 的 float 表单

html - 在同一行显示 HTML 元素

javascript - 悬停在父元素上时,显示子元素(下拉导航)

css - 如何使用内联 CSS 更改链接文本的字体颜色?

html - 两个文本区域以最小宽度并排,但当文本较长时折叠左侧