I was looking at a code made by a guy in twitter and it is like this :
div::after { -webkit-transform: rotate(2deg); } div ~ div { -webkit-transform: rotate(0deg); }
what is it ?
Definition and UsageThe ::before selector inserts something before the content of each selected element(s). Use the content property to specify the content to insert. Use the ::after selector to insert something after the content. Version: CSS2.
A nested & selects the parent element in both SASS and LESS. It's not just for pseudo elements, it can be used with any kind of selector.
Special welcome offer: get $100 of free credit. 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.
The & is a special selector invented by SCSS which is used in nested selectors to refer to the outer selector . It simply means that it will be replaced with the outer selector when compiling to CSS. There are some most commonly used cases: there is a space after the ampersand.
The double colon replaced the single-colon selectors for pseudo-elements in CSS3 to make an explicit distinction between pseudo-classes and pseudo-elements. For backward compatibility, the single-colon syntax is acceptable for pre-CSS3 selectors. So, :after is a pseudo-class and ::after is a pseudo-element.
The general sibling selector is available in CSS3, and the combinator used in this selector is a tilde character (~).
The selector matches elements that are siblings of a given element. This example will match a p element if it’s a sibling of an h2 element:
http://reference.sitepoint.com/css/generalsiblingselector
http://www.evotech.net/blog/2007/05/after-v-after-what-is-double-colon-notation/
The tilde character (~) is the siblings selector
h2 ~ p { color:red; }
for example would make the paragraphs red in the below code
<h2>Heading</h2> <p>The selector above matches this paragraph.</p> <p>The selector above matches this paragraph.</p>
the :: is used for ::before
and ::after
pseudo-elements which together with the content:
allow you to put, for example, an icon before every link
a::before { content:url(link.png); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With