forked from googlearchive/polymer-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styling-distributed-nodes.html
71 lines (56 loc) · 2.09 KB
/
styling-distributed-nodes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
# Styling distributed nodes
Shows the use of the `::content` pseudo element to style distributed nodes.
The `<content>` tag allows you to select and insert nodes into
predefined locations in your element. These locations are called insertion
points and the inserted nodes are called distributed nodes.
See [insertion point snippets](../insertion-points/) to learn more about the
`<content>` tag and distributed nodes.
The CSS `::content` pseudo-element is a way to style nodes that pass through an
insertion point:
::content p {
color: red;
}
::content .blue {
color: blue;
}
In this snippet, distributed `<p>` elements are red, and distributed `<p>`
elements _with the class "blue" are blue. You can use `<my-element>`
like this:
<my-element>
<p class="blue">Blue distributed node</p>
<p>Red distributed node</p>
</my-element>
Doing so generates this composed tree:
<p class="blue">Blue distributed node</p>
<p>Inside my-element</p>
<p>Red distributed node</p>
Note that since styles defined using `::content` apply only to distributed
nodes, the `<p>` sandwiched between the `<content>` tags in `<my-element>` is
not affected by them.
[jsbin](http://jsbin.com/lojeji/edit)
-->
<link rel="import" href="../../components/polymer/polymer.html">
<polymer-element name="my-element" noscript>
<template>
<style>
::content p {
color: red;
}
::content .blue {
color: blue;
}
</style>
<content select=".blue"></content>
<p>Inside my-element</p>
<content></content>
</template>
</polymer-element>