freeCodeCamp/challenges/01-responsive-web-design/css-grid.json

1561 lines
67 KiB
JSON

{
"name": "CSS Grid",
"order": 6,
"time": "5 hours",
"helpRoom": "Help",
"challenges": [
{
"id": "5a858944d96184f06fd60d61",
"title": "Create Your First CSS Grid",
"description": [
"Turn any HTML element into a grid container by setting its <code>display</code> property to <code>grid</code>. This gives you the ability to use all the other properties associated with CSS Grid.",
"<strong>Note</strong><br>In CSS Grid, the parent element is referred to as the <dfn>container</dfn> and its children are called <dfn>items</dfn>.",
"<hr>",
"Change the display of the div with the <code>container</code> class to <code>grid</code>."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>display</code> property with a value of <code>grid</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>display</code> property with a value of <code>grid</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "Feb 15, 2018",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" width: 100%;",
" background: LightGray;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036d038fddaf9a66b5d32",
"title": "Add Columns with grid-template-columns",
"description": [
"Simply creating a grid element doesn't get you very far. You need to define the structure of the grid as well. To add some columns to the grid, use the <code>grid-template-columns</code> property on a grid container as demonstrated below:",
"<blockquote>.container {<br>&nbsp;&nbsp;display: grid;<br>&nbsp;&nbsp;grid-template-columns: 50px 50px;<br>}</blockquote>",
"This will give your grid two columns that are 50px wide each.",
"The number of parameters given to the <code>grid-template-columns</code> property indicates the number of columns in the grid, and the value of each parameter indicates the width of each column.",
"<hr>",
"Give the grid container three columns that are <code>100px</code> wide each."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-columns</code> property with three units of <code>100px</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?100px\\s*?100px\\s*?100px\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-columns</code> property with three units of <code>100px</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "Feb 15, 2018",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036e138fddaf9a66b5d33",
"title": "Add Rows with grid-template-rows",
"description": [
"The grid you created in the last challenge will set the number of rows automatically. To adjust the rows manually, use the <code>grid-template-rows</code> property in the same way you used <code>grid-template-columns</code> in previous challenge.",
"<hr>",
"Add two rows to the grid that are <code>50px</code> tall each."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-rows</code> property with two units of <code>50px</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-rows\\s*?:\\s*?50px\\s*?50px\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-rows</code> property with two units of <code>50px</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 100px 100px 100px;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036ee38fddaf9a66b5d34",
"title": "Use CSS Grid units to Change the Size of Columns and Rows",
"description": [
"You can use absolute and relative units like <code>px</code> and <code>em</code> in CSS Grid to define the size of rows and columns. You can use these as well:",
"<code>fr</code>: sets the column or row to a fraction of the available space,",
"<code>auto</code>: sets the column or row to the width or height of its content automatically,",
"<code>%</code>: adjusts the column or row to the percent width of its container.",
"Here's the code that generates the output in the preview:",
"<blockquote>grid-template-columns: auto 50px 10% 2fr 1fr;</blockquote>",
"This snippet creates five columns. The first column is as wide as its content, the second column is 50px, the third column is 10% of its container, and for the last two columns; the remaining space is divided into three sections, two are allocated for the fourth column, and one for the fifth.",
"<hr>",
"Make a grid with three columns whose widths are as follows: 1fr, 100px, and 2fr."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-columns</code> property that has three columns with the following widths: <code>1fr, 100px, and 2fr</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?1fr\\s*?100px\\s*?2fr\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-columns</code> property that has three columns with the following widths: <code>1fr, 100px, and 2fr</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" /* modify the code below this line */",
" ",
" grid-template-columns: auto 50px 10% 2fr 1fr;",
" ",
" /* modify the code above this line */",
" grid-template-rows: 50px 50px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036ee38fddaf9a66b5d35",
"title": "Create a Column Gap Using grid-column-gap",
"description": [
"So far in the grids you have created, the columns have all been tight up against each other. Sometimes you want a gap in between the columns. To add a gap between the columns, use the <code>grid-column-gap</code> property like this:",
"<blockquote>grid-column-gap: 10px;</blockquote>",
"This creates 10px of empty space between all of our columns.",
"<hr>",
"Give the columns in the grid a <code>20px</code> gap."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-column-gap</code> property that has the value of <code>20px</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-column-gap\\s*?:\\s*?20px\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-column-gap</code> property that has the value of <code>20px</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036ee38fddaf9a66b5d36",
"title": "Create a Row Gap using grid-row-gap",
"description": [
"You can add a gap in between the rows of a grid using <code>grid-row-gap</code> in the same way that you added a gap in between columns in the previous challenge.",
"<hr>",
"Create a gap for the rows that is <code>5px</code> tall."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-row-gap</code> property that has the value of <code>5px</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-row-gap\\s*?:\\s*?5px\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-row-gap</code> property that has the value of <code>5px</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a9036ee38fddaf9a66b5d37",
"title": "Add Gaps Faster with grid-gap",
"description": [
"<code>grid-gap</code> is a shorthand property for <code>grid-row-gap</code> and <code>grid-column-gap</code> from the previous two challenges that's more convenient to use. If <code>grid-gap</code> has one value, it will create a gap between all rows and columns. However, if there are two values, it will use the first one to set the gap between the rows and the second value for the columns.",
"<hr>",
"Use <code>grid-gap</code> to introduce a <code>10px</code> gap between the rows and <code>20px</code> gap between the columns."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-gap</code> property that introduces <code>10px</code> gap between the rows and <code>20px</code> gap between the columns.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-gap\\s*?:\\s*?10px\\s*?20px\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-gap</code> property that introduces <code>10px</code> gap between the rows and <code>20px</code> gap between the columns.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .d1{background:LightSkyBlue;}",
" .d2{background:LightSalmon;}",
" .d3{background:PaleTurquoise;}",
" .d4{background:LightPink;}",
" .d5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
"<div class=\"container\">",
" <div class=\"d1\">1</div>",
" <div class=\"d2\">2</div>",
" <div class=\"d3\">3</div>",
" <div class=\"d4\">4</div>",
" <div class=\"d5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a90372638fddaf9a66b5d38",
"title": "Use grid-column to Control Spacing",
"description": [
"Up to this point, all the properties that have been discussed are for grid containers. The <code>grid-column</code> property is the first one for use on the grid items themselves.",
"The hypothetical horizontal and vertical lines that create the grid are referred to as <dfn>lines</dfn>. These lines are numbered starting with 1 at the top left corner of the grid and move right for columns and down for rows, counting upward.",
"This is what the lines look like for a 3x3 grid:",
"<div style=\"position:relative;margin:auto;background:Gainsboro;display:block;margin-top:100px;margin-bottom:50px;width:200px;height:200px;\"><p style=\"left:25%;top:-30%;font-size:130%;position:absolute;color:RoyalBlue;\">column lines</p><p style=\"left:0%;top:-15%;font-size:130%;position:absolute;color:RoyalBlue;\">1</p><p style=\"left:30%;top:-15%;font-size:130%;position:absolute;color:RoyalBlue;\">2</p><p style=\"left:63%;top:-15%;font-size:130%;position:absolute;color:RoyalBlue;\">3</p><p style=\"left:95%;top:-15%;font-size:130%;position:absolute;color:RoyalBlue;\">4</p><p style=\"left:-40%;top:45%;font-size:130%;transform:rotateZ(-90deg);position:absolute;\">row lines</p><p style=\"left:-10%;top:-10%;font-size:130%;position:absolute;\">1</p><p style=\"left:-10%;top:21%;font-size:130%;position:absolute;\">2</p><p style=\"left:-10%;top:53%;font-size:130%;position:absolute;\">3</p><p style=\"left:-10%;top:85%;font-size:130%;position:absolute;\">4</p><div style=\"left:0%;top:0%;width:5%;height:100%;background:RoyalBlue;position:absolute;\"></div><div style=\"left:31%;top:0%;width:5%;height:100%;background:RoyalBlue;position:absolute;\"></div><div style=\"left:63%;top:0%;width:5%;height:100%;background:RoyalBlue;position:absolute;\"></div><div style=\"left:95%;top:0%;width:5%;height:100%;background:RoyalBlue;position:absolute;\"></div><div style=\"left:0%;top:0%;width:100%;height:5%;background:black;position:absolute;\"></div><div style=\"left:0%;top:31%;width:100%;height:5%;background:black;position:absolute;\"></div><div style=\"left:0%;top:63%;width:100%;height:5%;background:black;position:absolute;\"></div><div style=\"left:0%;top:95%;width:100%;height:5%;background:black;position:absolute;\"></div></div>",
"To control the amount of columns an item will consume, you can use the <code>grid-column</code> property in conjunction with the line numbers you want the item to start and stop at.",
"Here's an example:",
"<blockquote>grid-column: 1 / 3;</blockquote>",
"This will make the item start at the first vertical line of the grid on the left and span to the 3rd line of the grid, consuming two columns.",
"<hr>",
"Make the item with the class <code>item5</code> consume the last two columns of the grid."
],
"tests": [
{
"text":
"<code>item5</code> class should have a <code>grid-column</code> property that has the value of <code>2 / 4</code>.",
"testString":
"assert(code.match(/.item5\\s*?{[\\s\\S]*grid-column\\s*?:\\s*?2\\s*?\\/\\s*?4\\s*?;[\\s\\S]*}/gi), '<code>item5</code> class should have a <code>grid-column</code> property that has the value of <code>2 / 4</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" ",
" .item5 {",
" background: PaleGreen;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a90373638fddaf9a66b5d39",
"title": "Use grid-row to Control Spacing",
"description": [
"Of course, you can make items consume multiple rows just like you can with columns. You define the horizontal lines you want an item to start and stop at using the <code>grid-row</code> property on a grid item.",
"<hr>",
"Make the element with the <code>item5</code> class consume the last two rows."
],
"tests": [
{
"text":
"<code>item5</code> class should have a <code>grid-row</code> property that has the value of <code>2 / 4</code>.",
"testString":
"assert(code.match(/.item5\\s*?{[\\s\\S]*grid-row\\s*?:\\s*?2\\s*?\\/\\s*?4\\s*?;[\\s\\S]*}/gi), '<code>item5</code> class should have a <code>grid-row</code> property that has the value of <code>2 / 4</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" ",
" .item5 {",
" background: PaleGreen;",
" grid-column: 2 / 4;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a90374338fddaf9a66b5d3a",
"title": "Align an Item Horizontally using justify-self",
"description": [
"In CSS Grid, the content of each item is located in a box which is referred to as a <dfn>cell</dfn>. You can align the content's position within its cell horizontally using the <code>justify-self</code> property on a grid item. By default, this property has a value of <code>stretch</code>, which will make the content fill the whole width of the cell. This CSS Grid property accepts other values as well:",
"<code>start</code>: aligns the content at the left of the cell,",
"<code>center</code>: aligns the content in the center of the cell,",
"<code>end</code>: aligns the content at the right of the cell.",
"<hr>",
"Use the <code>justify-self</code> property to center the item with the class <code>item2</code>."
],
"tests": [
{
"text":
"<code>item2</code> class should have a <code>justify-self</code> property that has the value of <code>center</code>.",
"testString":
"assert(code.match(/.item2\\s*?{[\\s\\S]*justify-self\\s*?:\\s*?center\\s*?;[\\s\\S]*}/gi), '<code>item2</code> class should have a <code>justify-self</code> property that has the value of <code>center</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background: LightSkyBlue;}",
" ",
" .item2 {",
" background: LightSalmon;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a90375238fddaf9a66b5d3b",
"title": "Align an Item Vertically using align-self",
"description": [
"Just as you can align an item horizontally, there's a way to align an item vertically as well. To do this, you use the <code>align-self</code> property on an item. This property accepts all of the same values as <code>justify-self</code> from the last challenge.",
"<hr>",
"Align the item with the class <code>item3</code> vertically at the <code>end</code>."
],
"tests": [
{
"text":
"<code>item3</code> class should have a <code>align-self</code> property that has the value of <code>end</code>.",
"testString":
"assert(code.match(/.item3\\s*?{[\\s\\S]*align-self\\s*?:\\s*?end\\s*?;[\\s\\S]*}/gi), '<code>item3</code> class should have a <code>align-self</code> property that has the value of <code>end</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" ",
" .item3 {",
" background: PaleTurquoise;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a90376038fddaf9a66b5d3c",
"title": "Align All Items Horizontally using justify-items",
"description": [
"Sometimes you want all the items in your CSS Grid to share the same alignment. You can use the previously learned properties and align them individually, or you can align them all at once horizontally by using <code>justify-items</code> on your grid container. This property can accept all the same values you learned about in the previous two challenges, the difference being that it will move <b>all</b> the items in our grid to the desired alignment.",
"<hr>",
"Use this property to center all our items horizontally."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>justify-items</code> property that has the value of <code>center</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*justify-items\\s*?:\\s*?center\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>justify-items</code> property that has the value of <code>center</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fdf869fb03452672e45b",
"title": "Align All Items Vertically using align-items",
"description": [
"Using the <code>align-items</code> property on a grid container will set the vertical alignment for all the items in our grid.",
"<hr>",
"Use it now to move all the items to the end of each cell."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>align-items</code> property that has the value of <code>end</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*align-items\\s*?:\\s*?end\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>align-items</code> property that has the value of <code>end</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe0569fb03452672e45c",
"title": "Divide the Grid Into an Area Template",
"description": [
"You can group cells of your grid together into an <dfn>area</dfn> and give the area a custom name. Do this by using <code>grid-template-areas</code> on the container like this:",
"<blockquote>grid-template-areas:<br>&nbsp;&nbsp;\"header header header\"<br>&nbsp;&nbsp;\"advert content content\"<br>&nbsp;&nbsp;\"footer footer footer\";</blockquote>",
"The code above merges the top three cells together into an area named <code>header</code>, the bottom three cells into a <code>footer</code> area, and it makes two areas in the middle row; <code>advert</code> and <code>content</code>.",
"<strong>Note</strong><br>Every word in the code represents a cell and every pair of quotation marks represent a row.",
"In addition to custom labels, you can use a period (<code>.</code>) to designate an empty cell in the grid.",
"<hr>",
"Place the area template so that the cell labeled <code>advert</code> becomes an empty cell."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-areas</code> property similar to the preview but has <code>.</code> instead of the <code>advert</code> area.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-areas\\s*?:\\s*?\"\\s*?header\\s*?header\\s*?header\\s*?\"\\s*?\"\\s*?.\\s*?content\\s*?content\\s*?\"\\s*?\"\\s*?footer\\s*?footer\\s*?footer\\s*?\"\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-areas</code> propertiy similar to the preview but has <code>.</code> instead of the <code>advert</code> area.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" /* change code below this line */",
" ",
" grid-template-areas:",
" \"header header header\"",
" \"advert content content\"",
" \"footer footer footer\";",
" /* change code above this line */",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe1369fb03452672e45d",
"title": "Place Items in Grid Areas Using the grid-area Property",
"description": [
"After creating an areas template for your grid container, as shown in the previous challenge, you can place an item in your custom area by referencing the name you gave it. To do this, you use the <code>grid-area</code> property on an item like this:",
"<blockquote>.item1 { grid-area: header; }</blockquote>",
"This lets the grid know that you want the <code>item1</code> class to go in the area named <code>header</code>. In this case, the item will use the entire top row because that whole row is named as the header area.",
"<hr>",
"Place an element with the <code>item5</code> class in the <code>footer</code> area using the <code>grid-area</code> property."
],
"tests": [
{
"text":
"<code>item5</code> class should have a <code>grid-area</code> property that has the value of <code>footer</code>.",
"testString":
"assert(code.match(/.item5\\s*?{[\\s\\S]*grid-area\\s*?:\\s*?footer\\s*?;[\\s\\S]*}/gi), '<code>item5</code> class should have a <code>grid-area</code> property that has the value of <code>footer</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" ",
" .item5 {",
" background: PaleGreen;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" grid-template-areas: ",
" \"header header header\"",
" \"advert content content\"",
" \"footer footer footer\";",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe2669fb03452672e45e",
"title": "Use grid-area Without Creating an Areas Template",
"description": [
"The <code>grid-area</code> property you learned in the last challenge can be used in another way. If your grid doesn't have an areas template to reference, you can create an area on the fly for an item to be placed like this:",
"<blockquote>item1 { grid-area: 1/1/2/4; }</blockquote>",
"This is using the line numbers you learned about earlier to define where the area for this item will be. The numbers in the example above represent these values:",
"<blockquote>grid-area: horizontal line to start at / vertical line to start at / horizontal line to end at / vertical line to end at;</blockquote>",
"So the item in the example will consume the rows between lines 1 and 2, and the columns between lines 1 and 4.",
"<hr>",
"Using the <code>grid-area</code> property, place the element with <code>item5</code> class between the third and fourth horizontal lines and between the first and fourth vertical lines."
],
"tests": [
{
"text":
"<code>item5</code> class should have a <code>grid-area</code> property that has the value of <code>3/1/4/4</code>.",
"testString":
"assert(code.match(/.item5\\s*?{[\\s\\S]*grid-area\\s*?:\\s*?3\\s*?\\/\\s*?1\\s*?\\/\\s*?4\\s*?\\/\\s*?4\\s*?;[\\s\\S]*}/gi), '<code>item5</code> class should have a <code>grid-area</code> property that has the value of <code>3/1/4/4</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" ",
" .item5 {",
" background: PaleGreen;",
" /* add your code below this line */",
" ",
" ",
" /* add your code above this line */",
" }",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr 1fr 1fr;",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe3669fb03452672e45f",
"title": "Reduce Repetition Using the repeat Function",
"description": [
"When you used <code>grid-template-columns</code> and <code>grid-template-rows</code> to define the structure of a grid, you entered a value for each row or column you created.",
"Lets say you want a grid with 100 rows of the same height. It isn't very practical to insert 100 values individually. Fortunately, there's a better way - by using the <code>repeat</code> function to specify the number of times you want your column or row to be repeated, followed by a comma and the value you want to repeat.",
"Here's an example that would create the 100 row grid, each row at 50px tall.",
"<blockquote>grid-template-rows: repeat(100, 50px);</blockquote>",
"You can also repeat multiple values with the repeat function, and insert the function amongst other values when defining a grid structure. Here's what I mean:",
"<blockquote>grid-template-columns: repeat(2, 1fr 50px) 20px;</blockquote>",
"This translates to:",
"<blockquote>grid-template-columns: 1fr 50px 1fr 50px 20px;</blockquote>",
"<strong>Note</strong><br><code>1fr 50px</code> is repeated twice followed by 20px.",
"<hr>",
"Use <code>repeat</code> to remove repetition from the <code>grid-template-columns</code> property."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-columns</code> property that is set to repeat 3 columns with the width of <code>1fr</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?repeat\\s*?\\(\\s*?3\\s*?,\\s*?1fr\\s*?\\)\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-columns</code> property that is set to repeat 3 columns with the width of <code>1fr</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" /* change the code below this line */",
" ",
" grid-template-columns: 1fr 1fr 1fr;",
" ",
" /* change the code above this line */",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe4469fb03452672e460",
"title": "Limit Item Size Using the minmax Function",
"description": [
"There's another built-in function to use with <code>grid-template-columns</code> and <code>grid-template-rows</code> called <code>minmax</code>. It's used to limit the size of items when the grid container changes size. To do this you need to specify the acceptable size range for your item. Here is an example:",
"<blockquote>grid-template-columns: 100px minmax(50px, 200px);</blockquote>",
"In the code above, <code>grid-template-columns</code> is set to create two columns; the first is 100px wide, and the second has the minimum width of 50px and the maximum width of 200px.",
"<hr>",
"Using the <code>minmax</code> function, replace the <code>1fr</code> in the <code>repeat</code> function with a column size that has the minimum width of <code>90px</code> and the maximum width of <code>1fr</code>, and resize the preview panel to see the effect."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-columns</code> property that is set to repeat 3 columns with the minimum width of <code>90px</code> and maximum width of <code>1fr</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?repeat\\s*?\\(\\s*?3\\s*?,\\s*?minmax\\s*?\\(\\s*?90px\\s*?,\\s*?1fr\\s*?\\)\\s*?\\)\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-columns</code> property that is set to repeat 3 columns with the minimum width of <code>90px</code> and maximum width of <code>1fr</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" /* change the code below this line */",
" ",
" grid-template-columns: repeat(3, 1fr);",
" ",
" /* change the code above this line */",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe5469fb03452672e461",
"title": "Create Flexible Layouts Using auto-fill",
"description": [
"The repeat function comes with a option called <dfn>auto-fill</dfn>. This allows you to automatically insert as many rows or columns of your desired size as possible depending on the size of the container. You can create flexible layouts when combining <code>auto-fill</code> with <code>minmax</code>.",
"In the preview, <code>grid-template-columns</code> is set to",
"<blockquote>repeat(auto-fill, minmax(60px, 1fr));</blockquote>",
"When the container changes size, this setup keeps inserting 60px columns and stretching them until it can insert another one.",
"<strong>Note</strong><br>If your container can't fit all your items on one row, it will move them down to a new one.",
"<hr>",
"In the first grid, use <code>auto-fill</code> with <code>repeat</code> to fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>. Then resize the preview to see auto-fill in action."
],
"tests": [
{
"text":
"<code>container</code> class should have a <code>grid-template-columns</code> property with <code>repeat</code> and <code>auto-fill</code> that will fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?repeat\\s*?\\(\\s*?auto-fill\\s*?,\\s*?minmax\\s*?\\(\\s*?60px\\s*?,\\s*?1fr\\s*?\\)\\s*?\\)\\s*?;[\\s\\S]*}/gi), '<code>container</code> class should have a <code>grid-template-columns</code> property with <code>repeat</code> and <code>auto-fill</code> that will fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 100px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" /* change the code below this line */",
" ",
" grid-template-columns: repeat(3, minmax(60px, 1fr));",
" ",
" /* change the code above this line */",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
" ",
" .container2 {",
" font-size: 40px;",
" min-height: 100px;",
" width: 100%;",
" background: Silver;",
" display: grid;",
" grid-template-columns: repeat(3, minmax(60px, 1fr));",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>",
"<div class=\"container2\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe6269fb03452672e462",
"title": "Create Flexible Layouts Using auto-fit",
"description": [
"<code>auto-fit</code> works almost identically to <code>auto-fill</code>. The only difference is that when the container's size exceeds the size of all the items combined, <code>auto-fill</code> keeps inserting empty rows or columns and pushes your items to the side, while <code>auto-fit</code> collapses those empty rows or columns and stretches your items to fit the size of the container.",
"<strong>Note</strong><br>If your container can't fit all your items on one row, it will move them down to a new one.",
"<hr>",
"In the second grid, use <code>auto-fit</code> with <code>repeat</code> to fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>. Then resize the preview to see the difference."
],
"tests": [
{
"text":
"<code>container2</code> class should have a <code>grid-template-columns</code> property with <code>repeat</code> and <code>auto-fit</code> that will fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>.",
"testString":
"assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?repeat\\s*?\\(\\s*?auto-fit\\s*?,\\s*?minmax\\s*?\\(\\s*?60px\\s*?,\\s*?1fr\\s*?\\)\\s*?\\)\\s*?;[\\s\\S]*}/gi), '<code>container2</code> class should have a <code>grid-template-columns</code> property with <code>repeat</code> and <code>auto-fit</code> that will fill the grid with columns that have a minimum width of <code>60px</code> and maximum of <code>1fr</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1{background:LightSkyBlue;}",
" .item2{background:LightSalmon;}",
" .item3{background:PaleTurquoise;}",
" .item4{background:LightPink;}",
" .item5{background:PaleGreen;}",
" ",
" .container {",
" font-size: 40px;",
" min-height: 100px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: repeat( auto-fill, minmax(60px, 1fr));",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
" ",
" .container2 {",
" font-size: 40px;",
" min-height: 100px;",
" width: 100%;",
" background: Silver;",
" display: grid;",
" /* change the code below this line */",
" ",
" grid-template-columns: repeat(3, minmax(60px, 1fr));",
" ",
" /* change the code above this line */",
" grid-template-rows: 1fr 1fr 1fr;",
" grid-gap: 10px;",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>",
"<div class=\"container2\">",
" <div class=\"item1\">1</div>",
" <div class=\"item2\">2</div>",
" <div class=\"item3\">3</div>",
" <div class=\"item4\">4</div>",
" <div class=\"item5\">5</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe7769fb03452672e463",
"title": "Use Media Queries to Create Responsive Layouts",
"description": [
"CSS Grid can be an easy way to make your site more responsive by using media queries to rearrange grid areas, change dimensions of a grid, and rearrange the placement of items.",
"In the preview, when the viewport width is 300px or more, the number of columns changes from 1 to 2. The advertisement area then occupies the left column completely.",
"<hr>",
"When the viewport width is <code>400px</code> or more, make the header area occupy the top row completely and the footer area occupy the bottom row completely."
],
"tests": [
{
"text":
"When the viewport is <code>400px</code> or more, <code>container</code> class should have a <code>grid-template-areas</code> property in which the footer and header areas occupy the top and bottom rows respectively and advert and content occupy the left and right columns of the middle row.",
"testString":
"assert(code.match(/@media\\s*?\\(\\s*?min-width\\s*?:\\s*?400px\\s*?\\)[\\s\\S]*.container\\s*?{[\\s\\S]*grid-template-areas\\s*?:\\s*?\"\\s*?header\\s*?header\\s*?\"\\s*?\"\\s*?advert\\s*?content\\s*?\"\\s*?\"\\s*?footer\\s*?footer\\s*?\"\\s*?;[\\s\\S]*}/gi), 'When the viewport is <code>400px</code> or more, <code>container</code> class should have a <code>grid-template-areas</code> property in which the footer and header areas occupy the top and bottom rows respectively and advert and content occupy the left and right columns of the middle row.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1 {",
" background: LightSkyBlue;",
" grid-area: header;",
" }",
" ",
" .item2 {",
" background: LightSalmon;",
" grid-area: advert;",
" }",
" ",
" .item3 {",
" background: PaleTurquoise;",
" grid-area: content;",
" }",
" ",
" .item4 {",
" background: lightpink;",
" grid-area: footer;",
" }",
" ",
" .container {",
" font-size: 1.5em;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: 1fr;",
" grid-template-rows: 50px auto 1fr auto;",
" grid-gap: 10px;",
" grid-template-areas:",
" \"header\"",
" \"advert\"",
" \"content\"",
" \"footer\";",
" }",
" ",
" @media (min-width: 300px){",
" .container{",
" grid-template-columns: auto 1fr;",
" grid-template-rows: auto 1fr auto;",
" grid-template-areas:",
" \"advert header\"",
" \"advert content\"",
" \"advert footer\";",
" }",
" }",
" ",
" @media (min-width: 400px){",
" .container{",
" /* change the code below this line */",
" ",
" grid-template-areas:",
" \"advert header\"",
" \"advert content\"",
" \"advert footer\";",
" ",
" /* change the code above this line */",
" }",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">header</div>",
" <div class=\"item2\">advert</div>",
" <div class=\"item3\">content</div>",
" <div class=\"item4\">footer</div>",
"</div>"
],
"head": [],
"tail": []
}
}
},
{
"id": "5a94fe8569fb03452672e464",
"title": "Create Grids within Grids",
"description": [
"Turning an element into a grid only affects the behavior of its direct descendants. So by turning a direct descendant into a grid, you have a grid within a grid.",
"For example, by setting the <code>display</code> and <code>grid-template-columns</code> properties of the element with the <code>item3</code> class, you create a grid within your grid.",
"<hr>",
"Turn the element with the <code>item3</code> class into a grid with two columns with a width of <code>auto</code> and <code>1fr</code> using <code>display</code> and <code>grid-template-columns</code>."
],
"tests": [
{
"text":
"<code>item3</code> class should have a <code>grid-template-columns</code> property with <code>auto</code> and <code>1fr</code> as values.",
"testString":
"assert(code.match(/.item3\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?auto\\s*?1fr\\s*?;[\\s\\S]*}/gi), '<code>item3</code> class should have a <code>grid-template-columns</code> property with <code>auto</code> and <code>1fr</code> as values.');"
},
{
"text":
"<code>item3</code> class should have a <code>display</code> property with the value of <code>grid</code>.",
"testString":
"assert(code.match(/.item3\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), '<code>item3</code> class should have a <code>display</code> property with the value of <code>grid</code>.');"
}
],
"solutions": [],
"hints": [],
"releasedOn": "",
"challengeType": 0,
"translations": {},
"files": {
"indexhtml": {
"key": "indexhtml",
"ext": "html",
"name": "index",
"contents": [
"<style>",
" .item1 {",
" background: LightSkyBlue;",
" grid-area: header;",
" }",
" ",
" .item2 {",
" background: LightSalmon;",
" grid-area: advert;",
" }",
" ",
" .item3 {",
" background: PaleTurquoise;",
" grid-area: content;",
" /* enter your code below this line */",
" ",
" ",
" /* enter your code above this line */",
" }",
" ",
" .item4 {",
" background: lightpink;",
" grid-area: footer;",
" }",
" ",
" .itemOne {",
" background: PaleGreen;",
" }",
" ",
" .itemTwo {",
" background: BlanchedAlmond;",
" }",
" ",
" .container {",
" font-size: 1.5em;",
" min-height: 300px;",
" width: 100%;",
" background: LightGray;",
" display: grid;",
" grid-template-columns: auto 1fr;",
" grid-template-rows: auto 1fr auto;",
" grid-gap: 10px;",
" grid-template-areas:",
" \"advert header\"",
" \"advert content\"",
" \"advert footer\";",
" }",
"</style>",
" ",
"<div class=\"container\">",
" <div class=\"item1\">header</div>",
" <div class=\"item2\">advert</div>",
" <div class=\"item3\">",
" <div class=\"itemOne\">paragraph1</div>",
" <div class=\"itemTwo\">paragraph2</div>",
" </div>",
" <div class=\"item4\">footer</div>",
"</div>"
],
"head": [],
"tail": []
}
}
}
]
}