UNPKG

6.48 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en-gb" dir="ltr">
3
4 <head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <title>Sticky - UIkit tests</title>
8 <script src="js/test.js"></script>
9 <style type="text/css">
10
11 #viewport { border: 1px dashed rgba(0,0,0,0.2); }
12
13 </style>
14 </head>
15
16 <body>
17
18 <div class="uk-container" style="height: 3500px;">
19
20 <h1>Sticky</h1>
21
22 <div id="viewport" class="uk-margin">
23 <div class="uk-grid uk-child-width-1-6" uk-height-viewport="offset-top: true">
24 <div>
25
26 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="offset: 50; bottom: #viewport">Stick to container; 50px offset</div>
27
28 </div>
29 <div>
30
31 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="top: 50vh; target-offset: 10">Sticky after 50vh; Scroll up if initially above paragraph below</div>
32
33 </div>
34 <div>
35
36 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="top: #viewport; animation: uk-animation-slide-top">Stick below container; animation</div>
37
38 </div>
39 <div>
40
41 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="bottom: #hash">Stick until next paragraph</div>
42
43 </div>
44 <div>
45
46 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="show-on-up: true; animation: uk-animation-slide-top">Sticky on scroll up; animation</div>
47
48 </div>
49 <div>
50
51 <div class="uk-card uk-card-primary uk-card-body" uk-sticky="top: 300; animation: uk-animation-slide-top; media: 640">Sticky after 300px scrolling; @media 640px</div>
52
53 </div>
54 </div>
55 </div>
56
57 <p id="hash" class="uk-margin-large">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
58
59 <h2>JavaScript Options</h2>
60
61 <div class="uk-overflow-auto">
62 <table class="uk-table uk-table-striped">
63 <thead>
64 <tr>
65 <th>Option</th>
66 <th>Value</th>
67 <th>Default</th>
68 <th>Description</th>
69 </tr>
70 </thead>
71 <tbody>
72 <tr>
73 <td><code>top</code></td>
74 <td>Number|% View Port Height|CSS Selector</td>
75 <td>0</td>
76 <td>The top offset from where the element should be stick.</td>
77 </tr>
78 <tr>
79 <td><code>bottom</code></td>
80 <td>Boolean|CSS Selector</td>
81 <td>false</td>
82 <td>The bottom offset until the element should stick. (true: parent element, prefixed with '!' a parent selector)</td>
83 </tr>
84 <tr>
85 <td><code>offset</code></td>
86 <td>String</td>
87 <td>0</td>
88 <td>The offset the Sticky should be fixed to.</td>
89 </tr>
90 <tr>
91 <td><code>animation</code></td>
92 <td>String</td>
93 <td>false</td>
94 <td>The animation to use.</td>
95 </tr>
96 <tr>
97 <td><code>cls-active</code></td>
98 <td>String</td>
99 <td>uk-active</td>
100 <td>The active class.</td>
101 </tr>
102 <tr>
103 <td><code>cls-inactive</code></td>
104 <td>String</td>
105 <td>''</td>
106 <td>The inactive class.</td>
107 </tr>
108 <tr>
109 <td><code>sel-target</code></td>
110 <td>CSS Selector</td>
111 <td>self</td>
112 <td>The target element to apply active and inactive classes to. Defaults to the element itself.</td>
113 </tr>
114 <tr>
115 <td><code>width-element</code></td>
116 <td>CSS Selector</td>
117 <td>false</td>
118 <td>The element the Sticky should get its with from in active mode.</td>
119 </tr>
120 <tr>
121 <td><code>show-on-up</code></td>
122 <td>Boolean</td>
123 <td>false</td>
124 <td>Only show sticky element when scrolling up.</td>
125 </tr>
126 <tr>
127 <td><code>media</code></td>
128 <td>Integer|String</td>
129 <td>false</td>
130 <td>Condition for the active status - a width as integer (e.g. 640) or a breakpoint (e.g. @s, @m, @l, @xl).</td>
131 </tr>
132 <tr>
133 <td><code>target-offset</code></td>
134 <td>Boolean, Number</td>
135 <td>false</td>
136 <td>Initially make sure that the Sticky is not over a targeted element via location hash.</td>
137 </tr>
138 </tbody>
139 </table>
140 </div>
141
142 </div>
143
144 </body>
145</html>