@@ -12,19 +12,27 @@ body {
1212 display : flex;
1313 justify-content : center;
1414 align-items : center;
15+ --custom-minwidth : 320px ;
16+ --custom-maxwidth : 1200px ;
1517}
1618
1719article {
20+ min-width : var (--custom-minwidth );
21+ max-width : var (--custom-maxwidth );
1822 position : relative;
19- min-width : 320px ;
20- max-width : 1200px ;
2123 width : 70% ;
2224 height : 600px ;
2325 border : 3px solid black;
2426}
2527
2628.progress {
27- width : calc ((progress (var (--container-width ), 320 , 1200 )) * 100% );
29+ width : calc (
30+ progress (
31+ var (--container-width ),
32+ var (--custom-minwidth ),
33+ var (--custom-maxwidth )
34+ ) * 100%
35+ );
2836 height : 4px ;
2937 background-color : red;
3038 position : absolute;
@@ -37,7 +45,11 @@ article {
3745 inset : 0 ;
3846 background-image : url (https://mdn.github.io/shared-assets/images/examples/wide-background.jpg);
3947 background-position-x : calc (
40- progress (var (--container-width ), 320 , 1200 ) * 100%
48+ progress (
49+ var (--container-width ),
50+ var (--custom-minwidth ),
51+ var (--custom-maxwidth )
52+ ) * 100%
4153 );
4254}
4355
@@ -46,13 +58,33 @@ article {
4658 inset : 0 ;
4759 padding : 20px ;
4860 background-color : rgb (
49- calc (255 * progress (var (--container-width ), 320 , 1200 ))
50- calc (255 * progress (var (--container-width ), 320 , 1200 )) 255 / 0.5
61+ calc (
62+ 255 *
63+ progress (
64+ var (--container-width ),
65+ var (--custom-minwidth ),
66+ var (--custom-maxwidth )
67+ )
68+ )
69+ calc (
70+ 255 *
71+ progress (
72+ var (--container-width ),
73+ var (--custom-minwidth ),
74+ var (--custom-maxwidth )
75+ )
76+ )
77+ 255 / 0.5
78+ );
79+ opacity : calc (
80+ (
81+ progress (
82+ var (--container-width ),
83+ var (--custom-minwidth ),
84+ var (--custom-maxwidth )
85+ ) / 2
86+ ) + 0.5
5187 );
52- opacity : calc ((progress (var (--container-width ), 320 , 1200 ) / 2 ) + 0.5 );
53-
54- /* Works without calc */
55- /* opacity: progress(var(--container-width), 320, 1200); */
5688}
5789
5890.content h1 ,
0 commit comments