English 中文(简体)
CSS3:unchecked pseudo-class
原标题:CSS3 :unchecked pseudo-class

我知道有一个正式的CSS3:checked。 页: 1 伪装阶级,他们是否有同样的浏览器支持?

http://tt.sitepoint.com/cs/pseudoclass-checked”rel=“noreferer”> 站点参考资料 但是,这只字不提:whatwg spec。 (无论是什么)都是这样做的。

我知道,如果将<代码>:checked和:not( pseudo-classes合并起来,但i m 仍然可治愈:

input[type="checkbox"]:not(:checked) {
    /* styles */
}

<><>Edit>:

第3条

可通过使用否定式假象选择一个不受控制的检查箱:

:not(:checked)
问题回答

I think you are trying to over complicate things. A simple solution is to just style your checkbox by default with the unchecked styles and then add the checked state styles.

input[type="checkbox"] {
  // Unchecked Styles
}
input[type="checkbox"]:checked {
  // Checked Styles
}

我很抱歉,要bringing起旧的read子,但感觉到,它本可以采用更好的答案。

EDIT (3/3/2016):

W3C Specs state that :not(:checked) as their example for selecting the unchecked state. However, this is explicitly the unchecked state and will only apply those styles to the unchecked state. This is useful for adding styling that is only needed on the unchecked state and would need removed from the checked state if used on the input[type="checkbox"] selector. See example below for clarification.

input[type="checkbox"] {
  /* Base Styles aka unchecked */
  font-weight: 300; // Will be overwritten by :checked
  font-size: 16px; // Base styling
}
input[type="checkbox"]:not(:checked) {
  /* Explicit Unchecked Styles */
  border: 1px solid #FF0000; // Only apply border to unchecked state
}
input[type="checkbox"]:checked {
  /* Checked Styles */
  font-weight: 900; // Use a bold font when checked
}

不用:not(:checked) in the example above:checked 选择人必须使用<条码>边界:无;以达到同样效果。

利用<条码>输入[类型=“盒式”]进行基础打字以减少重复。

使用<条码>输入[类型=“盒式”]:不适用(:打字)

我处理此事的方式是按某种条件改变标签的类别。 这样,你就只需要一个标签,你可以有不同的班级。 希望帮助!





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...