0

我有这个 LESS 设置。我想知道,有没有选择为两个父母之一筑巢?

 input[type="text"].text_field,
 textarea.text_field {
    // style for both

    textarea + & {
      // style for only text area
    }
  }

我需要添加一些其他样式textarea,我不想让它超出主要规则。那么,这可能吗?

4

2 回答 2

7

如果您想让它们保持相同的规则,您可以尝试这样的事情:

.text_field {
  color: black;

  input& {
    padding: 5px;
  }

  textarea& {
    padding: 5px;
  }
}
于 2013-04-17T15:49:23.587 回答
0
 input[type="text"].text_field, textarea.text_field {
    // style for both
    font-size: 15px;
    padding: 2px 5px;
 }
 textarea.text_field {
    // style for only text area, you can use !important if you want to use different style, and you used it in input[type="text"].text_field, textarea.text_field
    font-size: 13px !impotrant;
 }

嵌套示例:

 ul {
   // style
   li {
     // style
     a:link, a:hover, a:visited {
       // style: color, font-size, etc.
     }
     a:hover {
       text-decoration: underline;
     }
   }
 }
于 2013-04-17T15:48:28.093 回答