summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-size-replaced-001.html
blob: 27554b31353cf06c3e0a025bfceb23718b143eca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#propdef-anchor-name">
<link rel="author" href="mailto:kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/test-common.js"></script>
<style>
.container {
  position: relative;
  height: 10px;
}
.anchor1 {
  anchor-name: --a1;
  width: 5px;
  height: 24px;
  background: orange;
}
.target {
  position: absolute;
}
</style>
<body onload="checkLayoutForAnchorPos('.target')">
  <div class="container">
    <div class="anchor1"></div>

    <!-- Specifying the width or the height should scale uniformly. -->
    <img class="target" src="support/green-16x16.png"
      style="width: anchor-size(--a1 width)"
      data-expected-width=5 data-expected-height=5>
    <img class="target" src="support/green-16x16.png"
      style="height: anchor-size(--a1 width)"
      data-expected-width=5 data-expected-height=5>

    <!-- Smaller `min-width/height` than the natural size should be ignored. -->
    <img class="target" src="support/green-16x16.png"
      style="min-width: anchor-size(--a1 width)"
      data-expected-width=16 data-expected-height=16>
    <img class="target" src="support/green-16x16.png"
      style="min-height: anchor-size(--a1 width)"
      data-expected-width=16 data-expected-height=16>

    <!-- Larger `min-width/height` than the natural size should scale. -->
    <img class="target" src="support/green-16x16.png"
      style="min-width: anchor-size(--a1 height)"
      data-expected-width=24 data-expected-height=24>
    <img class="target" src="support/green-16x16.png"
      style="min-height: anchor-size(--a1 height)"
      data-expected-width=24 data-expected-height=24>

    <!-- Smaller `max-width/height` than the natural size should scale. -->
    <img class="target" src="support/green-16x16.png"
      style="max-width: anchor-size(--a1 width)"
      data-expected-width=5 data-expected-height=5>
    <img class="target" src="support/green-16x16.png"
      style="max-height: anchor-size(--a1 width)"
      data-expected-width=5 data-expected-height=5>

    <!-- Larger `min-width/height` than the natural size should be ignored. -->
    <img class="target" src="support/green-16x16.png"
      style="max-width: anchor-size(--a1 height)"
      data-expected-width=16 data-expected-height=16>
    <img class="target" src="support/green-16x16.png"
      style="max-height: anchor-size(--a1 height)"
      data-expected-width=16 data-expected-height=16>

    <!-- The `aspect-ratio` property should be honored. -->
    <img class="target" src="support/green-16x16.png"
      style="width: anchor-size(--a1 width); aspect-ratio: 0.5"
      data-expected-width=5 data-expected-height=10>
    <img class="target" src="support/green-16x16.png"
      style="height: anchor-size(--a1 width); aspect-ratio: 2"
      data-expected-width=10 data-expected-height=5>
  </div>
</body>