File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,42 @@ The 'scroll target group' property</h4>
250
250
251
251
</dl>
252
252
253
+ <div class='example'>
254
+ The following snippet demonstrates how to automatically highlight the currently visible chapter within a table of contents
255
+ <pre><code highlight="html">
256
+ <!DOCTYPE HTML>
257
+ <title>scroll-target-group example with a table of contents</title>
258
+ <style>
259
+ ol {
260
+ background-color: gray;
261
+ right: 10px;
262
+ top: 10px;
263
+ position: fixed;
264
+ /* Triggers the browser's algorithm for calculating :target-current. */
265
+ scroll-target-group: auto;
266
+ }
267
+
268
+ a:target-current {
269
+ color: red;
270
+ }
271
+
272
+ .chapter {
273
+ background: lightgray;
274
+ height: 60vh;
275
+ margin: 10px;
276
+ }
277
+ </style>
278
+ <ol>
279
+ <li><a href="#intro">Introduction</a></li>
280
+ <li><a href="#ch1">Chapter 1</a></li>
281
+ <li><a href="#ch2">Chapter 2</a></li>
282
+ </ol>
283
+ <div id="intro" class="chapter">Introduction content</div>
284
+ <div id="ch1" class="chapter">Chapter 1 content</div>
285
+ <div id="ch2" class="chapter">Chapter 2 content</div>
286
+ </code></pre>
287
+ </div>
288
+
253
289
<h4 id="scroll-marker-group-property">
254
290
The 'scroll-marker-group' property</h4>
255
291
You can’t perform that action at this time.
0 commit comments