targeted-column-scroll-marker-selection-003.html (3358B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 4 <head> 5 <meta charset="utf-8"> 6 <title>CSS Test: scroll tracking for ::scroll-markers whose orignatin elements cannot be scroll-aligned </title> 7 <link rel="match" href="targeted-column-scroll-marker-selection-003-ref.html"> 8 <link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-container-scroll"> 9 <script src="/css/css-transitions/support/helper.js"></script> 10 <script src="/dom/events/scrolling/scroll_support.js"></script> 11 <script src="/common/reftest-wait.js"></script> 12 </head> 13 14 <body> 15 <style> 16 .wrapper { 17 display: grid; 18 justify-content: center; 19 } 20 21 .carousel { 22 width: 800px; 23 height: 200px; 24 overflow-x: scroll; 25 scroll-snap-type: x mandatory; 26 list-style-type: none; 27 scroll-behavior: smooth; 28 border: solid 2px grey; 29 padding-top: 10%; 30 text-align: center; 31 counter-set: markeridx -1; 32 columns: 2; 33 34 /* Children 13 (index 12) and 16 (index 15) also generate scroll-markers, 35 along with all the ::columns. 36 */ 37 &::column::scroll-marker, 38 & >:nth-child(13)::scroll-marker, 39 & >:nth-child(16)::scroll-marker { 40 content: counter(markeridx); 41 counter-increment: markeridx; 42 align-content: center; 43 text-align: center; 44 width: 35px; 45 height: 35px; 46 border-radius: 50%; 47 margin: 3px; 48 background-color: red; 49 } 50 &::column::scroll-marker:target-current { 51 background-color: green; 52 } 53 &>:nth-child(13)::scroll-marker:target-current, 54 &>:nth-child(16)::scroll-marker:target-current { 55 background-color: lightgreen; 56 } 57 58 &>.item { 59 scroll-snap-align: center; 60 height: 80%; 61 width: 158px; 62 border: 1px solid; 63 place-content: center; 64 display: inline-block; 65 } 66 67 scroll-marker-group: after; 68 69 &::scroll-marker-group { 70 height: 45px; 71 display: flex; 72 align-items: center; 73 justify-content: center; 74 border: solid 1px black; 75 border-radius: 30px; 76 } 77 } 78 </style> 79 <div class="wrapper" id="wrapper"> 80 <div class="carousel" id="carousel"> 81 <div class="item item0" tabindex=0>0</div> 82 <div class="item item1" tabindex=0>1</div> 83 <div class="item item2" tabindex=0>2</div> 84 <div class="item item3" tabindex=0>3</div> 85 <div class="item item4" tabindex=0>4</div> 86 <div class="item item5" tabindex=0>5</div> 87 <div class="item item6" tabindex=0>6</div> 88 <div class="item item7" tabindex=0>7</div> 89 <div class="item item8" tabindex=0>8</div> 90 <div class="item item9" tabindex=0>9</div> 91 <div class="item item10" tabindex=0>10</div> 92 <div class="item item11" tabindex=0>11</div> 93 <div class="item item12" tabindex=0>12</div> 94 <div class="item item13" tabindex=0>13</div> 95 <div class="item item14" tabindex=0>14</div> 96 <div class="item item15" tabindex=0>15</div> 97 </div> 98 </div> 99 <script> 100 const items = document.querySelectorAll(".item"); 101 function runTest() { 102 const item14 = items[14]; 103 item14.scrollIntoView(); 104 carousel.onscrollend = () => { 105 takeScreenshot(); 106 }; 107 } 108 waitForCompositorReady().then(runTest); 109 </script> 110 </body> 111 112 </html>