custom-highlight-container-metrics-006.html (1237B)
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-002-ref.html"> 8 <meta name="assert" value="lengths depending on containers take the correct values inside and outside a container"> 9 <meta name="fuzzy" content="0-60;0-25"> 10 <head> 11 <style> 12 .wrapper { 13 container: wrapper / size; 14 width: 200px; 15 height: 100px; 16 } 17 ::highlight(highlight1) { 18 text-underline-offset: 2cqw; 19 text-decoration-line: underline; 20 text-decoration-color: green; 21 text-decoration-thickness: 4cqh; 22 } 23 </style> 24 </head> 25 <body> 26 <div id="h1" class="wrapper">With container size</div> 27 <div id="h2">Without container size</div> 28 <script> 29 let r1 = new Range(); 30 r1.setStart(h1, 0); 31 r1.setEnd(h1, 1); 32 let r2 = new Range(); 33 r2.setStart(h2, 0); 34 r2.setEnd(h2, 1); 35 CSS.highlights.set("highlight1", new Highlight(r1, r2)); 36 </script> 37 </body>