pseudo-element

::before pseudo-element stacking order issue

半城伤御伤魂 提交于 2019-11-26 22:53:39
When statically positioned, the ::before pseudo-element stacks (z-index) before the child's content, but after the child's background. Can anyone explain why or even how this is happening or if this is an issue that all major browsers have? <style> div { background-color:yellow; width:400px; } div::before { background-color:red; content:"div::before"; } div::after { background-color:green; content:"div::after"; } div p { background-color:blue; color:white; margin:-15px 0; padding:0; } </style> <div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sed tellus sed tellus

How can I make generated content selectable?

做~自己de王妃 提交于 2019-11-26 22:48:53
I can have CSS display the ID for an element by using generated content, like this: <style> h2:hover:after { color: grey; content: "#" attr(id); float: right; font-size: smaller; font-weight: normal; } </style> <h2 id="my-id">My ID</h2> <p>Pellentesque habitant morbi tristique senectus et netus et.</p> How can I make that generated content ("#my-id") selectable so that the user can highlight and copy it? You can't make a pseudo-element selectable, as it doesn't exist in the DOM. 5.10 Pseudo-elements and pseudo-classes Neither pseudo-elements nor pseudo-classes appear in the document source or

Are CSS3 ::before and ::after pseudo elements supported by IE9 or not?

谁都会走 提交于 2019-11-26 22:46:08
On this MS compatibility table it says, IE9 does not support pseudo-elements ::before and ::after , but when I try it seems it does... see JSBin Am I doing something wrong? I thought ::before and ::after would be nice tools to hide stuff from IE9, when in fact, they don't. The CSS2 pseudo-elements :before and :after , with the traditional single-colon notation, are supported by IE8 and later. They are not new to CSS3. The double-colon notation, on the other hand, is new to CSS3 . IE9 does support this new notation for ::before and ::after , and likewise for the CSS1 pseudo-elements ::first

What is the difference between pseudo-classes and pseudo-elements?

妖精的绣舞 提交于 2019-11-26 22:45:59
问题 What is the different between div::after {} and div:after {} ? When do we have to use :: over : ? Double colon and single-colon notation is to distinguish between pseudo-classes and pseudo-elements. What is the actual meaning of the above statement? 回答1: From https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Pseudo-classes_and_pseudo-elements Pseudo-class : A CSS pseudo-class is a keyword, preceded by a colon (:), added to the end of selectors to specify you want to style

Which elements support the ::before and ::after pseudo-elements?

梦想与她 提交于 2019-11-26 22:39:11
I'm trying to come up with some good default styling for <input> s in HTML5 and tried the following: input::after { display: inline; } input:valid::after { content: ' ✓ '; color: #ddf0dd; } input:invalid::after { content: ' ✗ '; color: #f0dddd; } Alas, the ::after content never shows up. It's not a problem with double- versus single colons for the pseudo-elements; I've tried both. It's also not a problem with having a pseudo-element and a pseudo-class; I've tried it without the :valid and :invalid . I get the same behavior in Chrome, Safari, and Firefox (Firefox doesn't have the :valid and

CSS pseudo-element to apply the first character of an element

馋奶兔 提交于 2019-11-26 22:04:59
问题 I have the following content in my h1 tag: "(Hello World)" so I add the following to my css to change the first character of this element: h1:first-letter { font-size:63px; color:#510007; font-family:Helvetica; } But, as I noticed, first-letter is only for letters, so is there any workarounds to apply this style to the first char? Which in this case is "(". 回答1: From the spec: Punctuation (i.e, characters defined in Unicode [UNICODE] in the "open" (Ps), "close" (Pe), "initial" (Pi). "final"

prevent a pseudo element from triggering hover?

社会主义新天地 提交于 2019-11-26 21:47:03
问题 If I have markup: <div class="a b"></div> where the .a class has a hover class associated with it and the .b class has a pseudo element associated with it... like so: div { width: 100px; height: 100px; } .a { background: red; display: inline-block; } .a:hover { background: green; } .b:after { content: ''; display: inline-block; width: 100px; height: 100px; margin-left: 100px; background: pink; } Is it possible with css to prevent a pseudo element from triggering the .a class hover? FIDDLE 回答1

Why does the CSS3 pseudo ::selection not change the color for all parts?

陌路散爱 提交于 2019-11-26 21:37:53
问题 Why does the CSS3 pseudo-element selection not change all parts of the highlight? As you can see in this screenshot I have selected part of the page, and parts of the selection are the default bright blue color: This is the CSS that I'm using, it is at the top of my CSS file: ::selection { background: #3B3B3B; color: #fff; } ::-moz-selection { background: #3B3B3B; color: #fff; } It seems like the highlight for inputs (text, checkboxes, etc.) and white space does not change. Does anyone know

Z-index with before pseudo-element

北城余情 提交于 2019-11-26 20:43:11
I've created a 'header' element with a before-pseudo element. the pseudeo element must be behind the parent element. Everything works great till the moment I give my 'header' a z-index. What I want: The yellow 'header' on the foreground, the red pseudo-element in the background and a simple z-index of 30 on the yellow 'header' element. header { background: yellow; position:relative; height: 100px; width: 100px; z-index:30; /*This is the problem*/ } header::before { content:"Hide you behind!"; background: red; position:absolute; height: 100px; width: 100px; top:25px; left:25px; z-index:-1; }

CSS :before on inline SVG

耗尽温柔 提交于 2019-11-26 20:40:17
Update Thanks porneL for pointing out the relation between generated content and replaced elements. I found this article which deals with this very topic: http://red-team-design.com/css-generated-content-replaced-elements/ Interestingly enough, a W3C document titled "CSS3 Generated and Replaced Content Module" (from 11 years ago!) defines the pseudo-element :outside , which could offer a solution to using generated content with replaced elements, by placing the generated content outside the replaced element, instead of trying to append it inside. Original question Is there a way to style an