Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a third pseudo element, like after and before

Tags:

css

I need something like third pseudo element for .foo.bar.

.foo.bar:before { content: "x "; }
.foo.bar:after { content: " x"; }

.foo.bar:before:before { content: "bad "; color: red; }
<div class="foo">apple</div>
<div class="foo bar">orange</div>
<div class="foo">chainsaw</div>
 
like image 865
Sojtin Avatar asked Aug 23 '16 08:08

Sojtin


People also ask

How many pseudo-elements can you have?

Syntax. You can use only one pseudo-element in a selector. It must appear after the simple selectors in the statement. Note: As a rule, double colons ( :: ) should be used instead of a single colon ( : ).

Can you have multiple pseudo-elements?

Multiple pseudo-elements can be created with the ::before(ordinal) and ::after(ordinal) notation, where 'ordinal' is a positive integer. ::before pseudo-elements are ordered descending by 'ordinal' from the host element's content edge.

Can I have multiple before pseudo-elements for the same element?

1, an element can only have at most one of any kind of pseudo-element at any time. (This means an element can have both a :before and an :after pseudo-element — it just cannot have more than one of each kind.)

What are pseudo-elements before and after?

CSS ::before and ::after pseudo-elements allow you to insert “content” before and after any non-replaced element (e.g. they work on a <div> but not an <input> ). This effectively allows you to show something on a web page that might not be present in the HTML content.


1 Answers

No. It's not possible (using CSS) to prepend to :before or :after's content: or in other words make a content:"x"; become bad x cause any defined rule will overwrite the old one, and there's no third to :before and :after

like image 87
Roko C. Buljan Avatar answered Oct 22 '22 21:10

Roko C. Buljan