pseudo-element

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

倖福魔咒の 提交于 2019-11-28 02:02:43
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 "(". From the spec : Punctuation (i.e, characters defined in Unicode [UNICODE] in the "open" (Ps), "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that precedes or follows the first letter should be included So

Change the :before selector from javascript [duplicate]

会有一股神秘感。 提交于 2019-11-28 01:56:20
问题 This question already has answers here : Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery (22 answers) Closed 3 months ago . How to change the :before content of #abc style from javascript ? <script> document.getElementById('abc').style.content='-'; </script> <style> #abc:before{content:"+";} </style> 回答1: No, you cannot access :before or :after from javascript, because they are not a part of the DOM. However you can still achieve your goal by using CSS

prevent a pseudo element from triggering hover?

北慕城南 提交于 2019-11-28 00:47:35
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 tessi The following css does the trick for modern browsers (not IE10-) : .b:after { pointer-events: none;

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

为君一笑 提交于 2019-11-28 00:02:23
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 why this is, and is there a way to change it for every part of the page so the highlight color is

To What Self-Closing Elements Can ::before and ::after Pseudo-Elements be Applied

Deadly 提交于 2019-11-27 23:31:52
I'm particularly interested in understanding when the ::before and ::after pseudo-elements can be applied to self-closing tags. This is the definition of these pseudo-elements, according to the W3 Generated Content CSS Specifications : 12.1 The :before and :after pseudo-elements : Authors specify the style and location of generated content with the :before and :after pseudo-elements. As their names indicate, the :before and :after pseudo-elements specify the location of content before and after an element's document tree content. The 'content' property, in conjunction with these pseudo

Overlapping circles bleeding

痞子三分冷 提交于 2019-11-27 22:32:40
问题 I have a position:relative green ring with a position:absolute red clone :before and a position:absolute white clone :after it covering both (since they are on the same place and have the same size). The problem is : it renders bad on both browsers tested (Chrome and Firefox) where I still can see the green/red rings under the white mask. Let the green ring with overflow:hidden partially fixes the problem removing the outer bleed; but the inner bleeding border stills there. Why does it

How to get pseudo element?

一世执手 提交于 2019-11-27 21:55:17
I need to get :after and assign it to variable. It is possible? querySelectorAll doesn't work. alert(some_div_with_pseudo.querySelectorAll('::after')[0]) // undefined The short answer is that you can’t. It’s not there yet. JavaScript has access to the DOM, which is built when the page is loaded from HTML, and modified further when JavaScript manipulates it. A pseudo element is generated by CSS, rather than HTML or JavaScript. It is there purely to give CSS something to hang on to, but it all happens without JavaScript having any idea. This is how it should be. In the overall scheme of things,

Pseudo elements breaking justify-content: space-between in flexbox layout

孤街浪徒 提交于 2019-11-27 21:24:30
I have three divs inside a parent div that are being spaced out using: display: flex; justify-content: space-between; However, the parent div has an :after on it which is making the three divs not go out to the edge of parent div. Is there a way to have flexbox ignore the :before and :after ? codepen.io .container { width: 100%; display: flex; justify-content: space-between; padding-top: 50px; background: gray; } .container div { background: red; height: 245px; width: 300px; } .container:before { content: ''; display: table; } .container:after { clear: both; content: ''; display: table; } <div

Event listener on a CSS pseudo-element, such as ::after and ::before?

霸气de小男生 提交于 2019-11-27 21:02:37
I have a div element with a CSS pseudo-element ::before used as a close button (instead of using an actual button). How do I apply an event listener to only the pseudo-element? HTML <div id="box"></div> CSS #box:before { background-image: url(close.png); content: ''; display: block; height: 20px; position: absolute; top: -10px; right: -10px; width: 20px; } #box { height: 100px; width: 100px; } Quentin No. The pseudo-element does not exist in the DOM so it has no HTMLElementNode object representing it. Was looking for a solution and found this thread. Now want to share my solution: CSS element

Can you add line breaks to the :after pseudo element?

守給你的承諾、 提交于 2019-11-27 20:57:46
I want to append a <br /> to a particular class. Using the :after pseudo class simply displays <br /> as text. Is there a way to make this work? It's internal for IE8 so browser issues aren't a problem. If I do <span class="linebreakclass">cats are</span> brilliant I want "brilliant" to appear on a new line. You won't be able to render HTML tags but you can set style like this: .needs-space:after { content: " "; display: block; clear: both; /* if you need to break floating elements */ } The main setting here is display: block; This will render :after content inside a DIV . And this pseudo