custom-highlight-container-metrics-005.html (1241B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Highlight API Test: Highlights using container sizes</title> 4 <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/"> 5 <link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling"> 6 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths"> 7 <link rel="match" href="custom-highlight-container-metrics-003-ref.html"> 8 <meta name="assert" value="a highlight on a container itself renders at the correct size"> 9 <head> 10 <style> 11 .wrapper { 12 container: wrapper / size; 13 width: 200px; 14 height: 100px; 15 } 16 @container (width > 100px) { 17 .wrapper::highlight(highlight1) { 18 text-underline-offset: 2cqw; 19 text-decoration-line: underline; 20 text-decoration-color: green; 21 text-decoration-thickness: 4cqh; 22 } 23 } 24 </style> 25 </head> 26 <body> 27 <div id="h1" class="wrapper">With container size</div> 28 <div id="h2">Should be no highlight</div> 29 <script> 30 let r1 = new Range(); 31 r1.setStart(h1, 0); 32 r1.setEnd(h1, 1); 33 let r2 = new Range(); 34 r2.setStart(h2, 0); 35 r2.setEnd(h2, 1); 36 CSS.highlights.set("highlight1", new Highlight(r1, r2)); 37 </script> 38 </body> 39 </html>