JSDM

HTML

65
 
1
// jade: compressed
2
3
mixin example(code)
4
  figcaption
5
    code= code
6
  figure&attributes(attributes)
7
    - for (var x = 0; x < 25; x++)
8
      i.fa.fa-circle
9
  br
10
  br
11
12
// Output HTML
13
14
h1.title :nth-child
15
16
main
17
  code :nth-child
18
  |  is a CSS3 selector, geared towards selecting children of an element depending on criteria.
19
  br
20
  br
21
  | What does that mean? In a nutshell, it means we can style elements depending on where they are in the DOM. This is great for selecting ranges of elements, or every "x" amount of elements!
22
  br
23
  br
24
  | In CSS, this looks like:
25
  pre
26
    | parent :nth-child( expression ) {
27
    |   *CSS*
28
    | }
29
  br
30
  br
31
  
32
  | Let's get down to some practical applications.
33
  br
34
  br
35
  hr
36
  | Styling a single element:
37
  +example( ":nth-child(9)" ).ex1
38
  
39
  | Styling above a certain element:
40
  +example( ":nth-child(n + 5)" ).ex2
41
  
42
  | Styling below a certain element:
43
  +example( ":nth-child(-n + 5)" ).ex3
44
  
45
  | Styling a range of elements:
46
  +example( ":nth-child(n + 10):nth-child(-n + 20)").ex4
47
  
48
  | Styling odd elements:
49
  +example( ":nth-child(odd)" ).ex5
50
  
51
  | Styling every x elements:
52
  +example( ":nth-child(5n + 1)").ex6
53
  
54
  | Style every odd element in a range:
55
  +example( ":nth-child(odd):nth-child(n + 10):nth-child(-n + 20)").ex7
56
  
57
  hr
58
  
59
  | As you can see, nth-child has some powerful applications. But remember, as always, with great power comes great responsibility; these selectors can be slow if applied too liberally!
60
  br
61
  br
62
  | Browser Campatability is pretty excellent; everything except IE8 has full support for the selector. 
63
  a(href="http://caniuse.com/#search=nth-child") Can-I-Use
64
  
65
!

CSS

xxxxxxxxxx
108
 
1
// Imports //
2
@import url("//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css");
3
4
// Block Elements //
5
6
body
7
  background #222
8
9
  color #ccc
10
  font-family "Open Sans", sans-serif
11
  line-height 1.3em
12
  font-size 1em
13
14
a
15
  color #09c
16
17
  text-decoration none
18
  transition text-shadow .2s, color .2s
19
  
20
  &:hover
21
    color #2be
22
    
23
    text-shadow 0 0 1px @color
24
25
code
26
  padding .1em .3em
27
      
28
  background #111
29
  
30
  font-family monospace
31
  
32
  border-radius .3em
33
34
pre
35
  @extends code
36
  line-height 1em
37
38
hr
39
  margin 2em 0
40
41
  border none
42
  border-top 1px solid #333
43
      
44
h1
45
  margin .5em 0
46
47
  font-size 2.5em
48
  font-weight 300
49
  line-height 1em
50
  text-align center
51
  
52
  text-shadow 0 0 2px white
53
  
54
  &.title
55
    margin .5em .5em .75em .5em
56
57
    font-size 4em
58
59
h2
60
  padding-left 1em
61
      
62
  margin .5em 0
63
64
  font-size 2em
65
  font-weight 300
66
  
67
  text-shadow 0 0 1px white
68
69
main
70
  max-width 800px
71
  padding-top 2em
72
  margin 0 auto 2em auto
73
  
74
75
  border-top 1px solid #333
76
77
figure
78
  box-sizing border-box
79
80
  width 100%
81
  padding 1em
82
  
83
  background #111
84
  
85
  text-align center
86
87
  border-radius .3em
88
89
figcaption
90
  line-height 1em
91
92
i.fa.fa-circle
93
  margin .5em
94
  
95
  color #444
96
97
figure.ex1 :nth-child( 9 ),
98
figure.ex2 :nth-child( n + 5 ),
99
figure.ex3 :nth-child( -n + 5 ),
100
figure.ex4 :nth-child(n + 10):nth-child(-n + 20),
101
figure.ex5 :nth-child(odd),
102
figure.ex6 :nth-child( 5n + 1 ),
103
figure.ex7 :nth-child(odd):nth-child(n + 10):nth-child(-n + 20)
104
  color #999
105
106
  text-shadow 0 0 1em white
107
108
!
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

1
 
1
!
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................