:没有选择器css不在字段选择上工作

时间:2014-07-12 00:43:26

标签: html css3

以下代码不显示预期结果。

form p label:not(label[for=id_cc_myself]) {
        display: block;
        margin-bottom: 3px;
}

相反,此样式语句根本没有选择label。虽然它不是有效的CSS3吗?

这是相关的html:

<form action="contact/" method="post">
  <h3>Contact form</h3>
  <div class="note">
    <img src="/static/core/img/info_icon.png" alt="info"><span>Please make sure to fill out all the fields below.</span>
  </div>
  <p>
    <label for="id_subject">Subject:</label>
    <input id="id_subject" maxlength="100" name="subject" type="text">
  </p>
  <p>
    <label for="id_sender">Your email address:</label>
    <input id="id_sender" name="sender" type="email"> <span class="helptext">you@example.com</span>
  </p>
  <p>
    <label for="id_message">Message:</label>
    <textarea cols="40" id="id_message" name="message" rows="10"></textarea>
  </p>
  <p>
    <label for="id_cc_myself">Send me a copy of this message:</label>
    <input id="id_cc_myself" name="cc_myself" type="checkbox">
  </p>
  <input type="submit" value="Submit">
</form>

:not选择器是否允许在嵌套字段选择中播放?

1 个答案:

答案 0 :(得分:1)

这应该这样做

form p label:not([for="id_cc_myself"]) {
    display: block;
    margin-bottom: 3px;
}

你可以在这里看到一个例子:

http://jsfiddle.net/DFxv6/