anchor-position-inline-004.html (5186B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#propdef-anchor-name"> 3 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-pos"> 4 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-size"> 5 <link rel="author" href="mailto:kojii@chromium.org"> 6 <link rel="author" href="mailto:mstensho@chromium.org"> 7 <link rel="match" href="anchor-position-inline-004-ref.html"> 8 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 9 <style> 10 body > div { 11 font-family: Ahem; 12 font-size: 10px; 13 line-height: 1; 14 width: 10em; 15 } 16 .cb { 17 position: relative; 18 } 19 body > .cb { 20 margin-bottom: 20px; 21 } 22 .columns { 23 column-count: 3; 24 column-fill: auto; 25 column-gap: 1em; 26 column-width: 10em; 27 orphans: 1; 28 widows: 1; 29 width: 32em; 30 height: 50px; 31 } 32 .anchor1 { 33 anchor-name: --a1; 34 color: red; 35 } 36 .target { 37 position: absolute; 38 } 39 .target1-pos { 40 left: anchor(--a1 left); 41 top: anchor(--a1 top); 42 right: anchor(--a1 right); 43 bottom: anchor(--a1 bottom); 44 } 45 .target1-size { 46 left: anchor(--a1 left); 47 top: anchor(--a1 top); 48 width: anchor-size(--a1 width); 49 height: anchor-size(--a1 height); 50 } 51 .target::before { 52 position: absolute; 53 background: green; 54 content: ""; 55 } 56 .target.part1::before { 57 width: 30%; 58 height: 50%; 59 } 60 .target.part2::before { 61 left: 30%; 62 width: 30%; 63 height: 50%; 64 } 65 .target.part3::before { 66 left: 60%; 67 width: 40%; 68 height: 50%; 69 } 70 .target.part4::before { 71 top: 50%; 72 width: 30%; 73 height: 50%; 74 } 75 .target.part5::before { 76 top: 50%; 77 left: 30%; 78 width: 30%; 79 height: 50%; 80 } 81 .target.part6::before { 82 top: 50%; 83 left: 60%; 84 width: 40%; 85 height: 50%; 86 } 87 #mc_part1::before { 88 width: 40px; 89 height: 25px; 90 } 91 #mc_part2::before { 92 left: 40px; 93 width: 40px; 94 height: 25px; 95 } 96 #mc_part3::before { 97 top: 25px; 98 width: 40px; 99 height: 25px; 100 } 101 #mc_part4::before { 102 top: 25px; 103 left: 40px; 104 width: 40px; 105 height: 25px; 106 } 107 </style> 108 <p>There should be no red below, only green.</p> 109 110 <!-- The inline anchor appear in a single line inline containing block. --> 111 <div class="cb" style="color:transparent;"> 112 <div><br></div> 113 <div> 114 0 115 <span class="cb"> 116 12 117 <span class="anchor1">a1</span> 118 34 119 <span class="target target1-pos part1"></span> 120 <span class="target target1-size part2"></span> 121 </span> 122 <span class="target target1-pos part3"></span> 123 <span class="target target1-size part4"></span> 124 </div> 125 <span class="target target1-pos part5"></span> 126 <span class="target target1-size part6"></span> 127 </div> 128 129 <!-- The inline anchor and inline containing block wrap to two lines. --> 130 <div class="cb" style="color:red;"> 131 <div> 132 0 133 <span class="cb"> 134 12 135 <span class="anchor1">a1 a1 a1</span> 136 345 137 <span class="target target1-pos part1"></span> 138 <span class="target target1-size part2"></span> 139 </span> 140 <span class="target target1-pos part3"></span> 141 <span class="target target1-size part4"></span> 142 </div> 143 <span class="target target1-pos part5"></span> 144 <span class="target target1-size part6"></span> 145 </div> 146 147 <!-- The inline anchor and inline containing block have forced line breaks. --> 148 <div class="cb" style="color:red;"> 149 <div> 150 0 151 <span class="cb"> 152 12 153 <span class="anchor1">a1<br>a1</span> 154 345 155 <span class="target target1-pos part1"></span> 156 <span class="target target1-size part2"></span> 157 </span> 158 <span class="target target1-pos part3"></span> 159 <span class="target target1-size part4"></span> 160 </div> 161 <span class="target target1-pos part5"></span> 162 <span class="target target1-size part6"></span> 163 </div> 164 165 <!-- The inline anchor and inline containing block wrap to two columns. --> 166 <div class="cb columns" style="color:red;"> 167 <div class="spacer" style="height: 90px"></div> 168 <div> 169 0 170 <span class="cb"> 171 12 172 <!-- The anchor begins at the end of the last line in one column, and 173 ends on the first line in the next column.--> 174 <span class="anchor1">a1 a1 a1</span> 175 345 176 <!-- The containing block of the next two anchor-positioned elements are 177 part of the fragmentation context. The anchor rectangle is the 178 bounding box of the two fragments (one on each line) within the 179 fragmented flow, pretending that everything is stacked on top of 180 each other (the final visual position of the columns is not 181 something we can (or should) see from within the fragmentation 182 context. Fill the parts that are not filled by the final four 183 elements (see below). --> 184 <span class="target target1-pos" style="color: green;"> 185 0 12 186 </span> 187 <span class="target target1-size" style="color:green;"> 188 <br> 345 189 </span> 190 </span> 191 <!-- The containing block of the below anchor-positioned elements are not 192 part of the fragmentation context. --> 193 <span class="target target1-pos" id="mc_part1"></span> 194 <span class="target target1-size" id="mc_part2"></span> 195 </div> 196 <span class="target target1-pos" id="mc_part3"></span> 197 <span class="target target1-size" id="mc_part4"></span> 198 </div>