Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Grid Layout Test: getComputedStyle().gridTemplateRows</title>
<meta name="assert" content="grid-template-rows computed value is the keyword none or a computed track list.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<style>
#target {
display: grid;
font-size: 40px;
min-width: 200px;
width: 300px;
max-width: 400px;
min-height: 500px;
height: 600px;
max-height: 700px;
}
#child {
min-width: 20px;
width: 30px;
max-width: 40px;
min-height: 50px;
height: 60px;
max-height: 70px;
}
</style>
</head>
<body>
<div id="container">
<div id="target">
<div id="child"></div>
</div>
</div>
<script>
test_computed_value("grid-template-rows", 'none', '600px'); // "none" without #child
// track-size <fixed-breadth> = <length-percentage> | <flex> | min-content | max-content | auto
test_computed_value("grid-template-rows", '20%', '120px'); // 20% * height
test_computed_value("grid-template-rows", 'calc(-0.5em + 10px)', '0px');
test_computed_value("grid-template-rows", 'calc(0.5em + 10px)', '30px');
test_computed_value("grid-template-rows", 'calc(30% + 40px)', '220px'); // 30% * height + 40px
test_computed_value("grid-template-rows", '5fr', '600px'); // height
test_computed_value("grid-template-rows", 'min-content', '60px');
test_computed_value("grid-template-rows", 'max-content', '60px');
test_computed_value("grid-template-rows", 'auto', '600px'); // height
// track-size minmax( <inflexible-breadth> , <track-breadth> )
test_computed_value("grid-template-rows", 'minmax(10px, auto)', '600px'); // height
test_computed_value("grid-template-rows", 'minmax(20%, max-content)', '120px'); // 20% * height
test_computed_value("grid-template-rows", 'minmax(min-content, calc(-0.5em + 10px))', '60px');
test_computed_value("grid-template-rows", 'minmax(auto, 0)', '60px');
// track-size fit-content( <length-percentage> )
test_computed_value("grid-template-rows", 'fit-content(70px)', '60px');
test_computed_value("grid-template-rows", 'fit-content(20%)', '60px');
test_computed_value("grid-template-rows", 'fit-content(calc(-0.5em + 10px))', '60px');
// <track-repeat> = repeat( [ <positive-integer> ] , [ <line-names>? <track-size> ]+ <line-names>? )
test_computed_value("grid-template-rows", 'repeat(1, 10px)', '10px');
test_computed_value("grid-template-rows", 'repeat(1, [one two] 20%)', '[one two] 120px');
test_computed_value("grid-template-rows", 'repeat(2, minmax(10px, auto))', '325px 275px');
test_computed_value("grid-template-rows", 'repeat(2, fit-content(20%) [three four] 30px 40px [five six])',
'60px [three four] 30px 40px [five six] 0px [three four] 30px 40px [five six]');
// <track-list> = [ <line-names>? [ <track-size> | <track-repeat> ] ]+ <line-names>?
test_computed_value("grid-template-rows", 'min-content repeat(5, minmax(10px, auto))',
'60px 108px 108px 108px 108px 108px');
test_computed_value("grid-template-rows", '[] 150px [] 1fr []', '150px 450px');
// <auto-repeat> = repeat( [ auto-fill | auto-fit ] , [ <line-names>? <fixed-size> ]+ <line-names>? )
test_computed_value("grid-template-rows", 'repeat(auto-fill, 200px)', '200px 200px 200px');
test_computed_value("grid-template-rows", 'repeat(auto-fit, [one] 20%)',
'[one] 120px [one] 0px [one] 0px [one] 0px [one] 0px');
test_computed_value("grid-template-rows", 'repeat(auto-fill, minmax(100px, 5fr) [two])',
'100px [two] 100px [two] 100px [two] 100px [two] 100px [two] 100px [two]');
test_computed_value("grid-template-rows", 'repeat(auto-fit, [three] minmax(max-content, 6em) [four])',
'[three] 240px [four three] 0px [four]');
// <auto-track-list> =
// [ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>?
// <auto-repeat>
// [ <line-names>? [ <fixed-size> | <fixed-repeat> ] ]* <line-names>?
test_computed_value("grid-template-rows", '[one] repeat(2, minmax(50px, auto)) [two] 30px [three] repeat(auto-fill, 10px) 40px [four five] repeat(2, minmax(200px, auto)) [six]',
'[one] 50px 50px [two] 30px [three] 10px 10px 10px 40px [four five] 200px 200px [six]');
</script>
</body>
</html>