pseudo-class

How do you add pseudo classes to elements using jQuery?

别来无恙 提交于 2019-11-26 17:49:11
In CSS, when you hover your mouse over an element, you can specify views for it using the :hover pseudo class: .element_class_name:hover { /* stuff here */ } How can you use jquery to add or "turn on" this pseudo class? Typically in jQuery if you want to add a class you would do: $(this).addClass("class_name"); I have tried "hover" but this literally adds a class named "hover" to the element. If anyone knows what to write, please let me know! Thanks! You can't force a certain pseudo-class to apply using jQuery. That's not how pseudo-classes (especially dynamic pseudo-classes) work, since they

Why doesn't nth-of-type/nth-child work on nested elements?

时光毁灭记忆、已成空白 提交于 2019-11-26 14:43:24
I'm trying to change the style of odd divs that are inside a div. For some reason the nth-of-type(odd) is affecting all my divs when it's inside another div. Here is my code for both the regular div and the odd divs: .video-entry-summary { width: 214px; height: 210px; margin-left: 10px; float: left; position: relative; overflow: hidden; border: 1px solid black; } .video-entry-summary:nth-of-type(odd) { width: 214px; height: 210px; margin-left: 0px; float: left; position: relative; overflow: hidden; border: 1px solid black; background: #ccc; } <div id="post-501" class="post-501 post type-post

Does CSS have a :blur selector (pseudo-class)?

谁都会走 提交于 2019-11-26 13:37:28
I know there is a :focus selector. I can't seem to find use of or documentation of a :blur selector. Is there one? There is no :blur pseudo-class in CSS. The dynamic pseudo-classes , like other pseudo-classes and in fact all other selectors, represent states ; they do not represent events or transitions between states in terms of the document tree. To wit: the :focus pseudo-class represents an element that is in focus; it does not represent an element that has just received focus, nor does there exist a :blur pseudo-class to represent an element that has just lost focus. Similarly, this

Should I use CSS :disabled pseudo-class or [disabled] attribute selector or is it a matter of opinion?

本秂侑毒 提交于 2019-11-26 12:43:53
问题 I\'m trying to style a disabled input. I can use: .myInput[disabled] { } or .myInput:disabled { } Is the attribute selector the modern CSS3 way and the way to go forward? I used to use the pseudo-class, but I can\'t find any info on whether they are the old way and won\'t be supported or whether they\'re both equal and you can use whatever you like best. I have no need to support older browsers (it\'s an intranet application), so is it: attribute is newer and better pseudo-class is still the

What&#39;s the difference between html[lang=“en”] and html:lang(en) in CSS?

牧云@^-^@ 提交于 2019-11-26 12:28:29
问题 The CSS language pseudo-class to allow us specify different styles for different languages, like so: html:lang(en) .foo { ... } However, this doesn\'t work in IE7, so I\'ve been using an attribute selector: html[lang=\"en\"] .foo { ... } They seem to do the same thing, but are there any subtle differences? And if not, why does CSS even have a language pseudo-class, when the attribute selector does the exact same thing? 回答1: In HTML, both the :lang() pseudo-class and the attribute selector

:active pseudo-class doesn&#39;t work in mobile safari

▼魔方 西西 提交于 2019-11-26 11:31:51
In Webkit on iPhone/iPad/iPod, specifying styling for an :active pseudo-class for an <a> tag doesn't trigger when you tap on the element. How can I get this to trigger? Example code: <style> a:active { background-color: red; } </style> <!-- snip --> <a href="#">Click me</a> wilsonpage <body ontouchstart=""> ... </body> Applied just once, as opposed to every button element seemed to fix all buttons on the page. Alternatively you could use this small JS library called ' Fastclick '. It speed up click events on touch devices and takes care of this issue too. user128216 As other answers have

How to select the first, second, or third element with a given class name?

淺唱寂寞╮ 提交于 2019-11-26 07:27:57
问题 How can I select a certain element in a list of elements? I have the following: <div class=\"myclass\">my text1</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <div> <p>more stuff</p> </div> <p> <span>Hello World</span> </p> <div class=\"myclass\">my text2</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <p> <span>Hello World</span> </p> <input type=\"\"/> <div class=\"myclass\">my text3</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <footer

heading with horizontal line on either side [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-11-26 07:27:27
问题 This question already has an answer here: Line before and after title over image [duplicate] 2 answers I am working on some CSS where the design calls for page titles (headings) to be centered with horizontal lines that are vertically centered on either side. Further, there is a background image on the page so the background of the title needs to be transparent. I have centered the title and I can use pseudo class to create the line. But I need the line disappear when it cross the text of the

How do you add pseudo classes to elements using jQuery?

爱⌒轻易说出口 提交于 2019-11-26 05:35:11
问题 In CSS, when you hover your mouse over an element, you can specify views for it using the :hover pseudo class: .element_class_name:hover { /* stuff here */ } How can you use jquery to add or \"turn on\" this pseudo class? Typically in jQuery if you want to add a class you would do: $(this).addClass(\"class_name\"); I have tried \"hover\" but this literally adds a class named \"hover\" to the element. If anyone knows what to write, please let me know! Thanks! 回答1: You can't force a certain

What is the difference between :focus and :active?

旧街凉风 提交于 2019-11-26 04:30:33
问题 What is the difference between the :focus and :active pseudo-classes? 回答1: :focus and :active are two different states. :focus represents the state when the element is currently selected to receive input and :active represents the state when the element is currently being activated by the user. For example let's say we have a <button> . The <button> will not have any state to begin with. It just exists. If we use Tab to give "focus" to the <button> , it now enters its :focus state. If you