html - :not selector css not working on field selection

标签 html css

下面的代码没有显示预期的结果。

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

相反,此样式语句根本没有选择任何标签。它不是有效的 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 选择器是否允许在嵌套字段选择上播放?

最佳答案

应该这样做

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

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

http://jsfiddle.net/DFxv6/

关于html - :not selector css not working on field selection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24708521/

相关文章:

javascript - 如何创建可折叠的网格、表格或列

css - 显示 :table row 内 div 的水平居中

jquery - 检测不同类型的滚动条(例如正常/隐藏的 osx)

html - 用任意字符替换 HTML 列表的元素符号

html - thymeleaf <img> 里面 <div th :text>

javascript - 将表单数据从表单的 View 传递到 Controller

javascript - Bootstrap 标题和主体的行在 Bootstrap 响应表中未正确对齐

javascript - 在使用 Javascript 进行鼠标悬停时,我有一个单独的 div 更改颜色但我需要在使用后重置该功能?

html - 仅在 Webkit 浏览器中以中心为中心的菜单丢失元素

javascript - 使用 CSS 将表情符号文本替换为图像