Unit IV - Grids - Lesson 1 - Part 1

5.1.1. Select the correct answer

(d) CSS Grid Layout

5.1.2. grid-template-rows, grid-template-columns

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">A</div>
			<div class="grid-item">B</div>
			<div class="grid-item">C</div>
			<div class="grid-item">D</div>
			<div class="grid-item">E</div>
			<div class="grid-item">F</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: skyblue;
	border: 1px solid white;
}
.grid-container {
	display: grid;
	grid-template-rows: repeat(2, 100px);
	grid-template-columns: repeat(3, 100px);
}

5.1.3. grid-area, grid-template-areas

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="header">Header</div>
			<div class="sidebar">Sidebar</div>
			<div class="main">Main</div>
			<div class="footer">Footer</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-container {
	display: grid;
	height: 100vh;
	grid-template-areas:
		"header header header"
		"sidebar main main"
		"footer footer footer";
	grid-template-rows: auto auto auto;
	grid-template-columns: auto auto auto;
}
.header {
	grid-area: header;
	background-color: red;
}
.sidebar {
	grid-area: sidebar;
	background-color: black;
}
.main {
	grid-area: main;
	background-color: blue;
}
.footer {
	grid-area: footer;
	background-color: skyblue;
}
* {
	margin: 0;
	color: white;
	text-align: center;
	font-size: 30px;
	border: 1px solid white;
}

5.1.4. grid-template

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">1</div>
			<div class="grid-item">2</div>
			<div class="grid-item">3</div>
			<div class="grid-item">4</div>
			<div class="grid-item">5</div>
			<div class="grid-item">6</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: red;
	border: 1px solid white;
}
.grid-container {
	display: grid;
	grid-template-rows: 100px 100px;
	grid-template-columns: 50px 50px 50px;
}

5.1.5. row-gap, column-gap

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">A</div>
			<div class="grid-item">B</div>
			<div class="grid-item">C</div>
			<div class="grid-item">D</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: seagreen;
	color: white;
	text-align: center;
}
.grid-container {
	display: grid;
	grid-template-rows: repeat(2, 100px);
	grid-template-columns: repeat(2, 100px);
	row-gap: 20px;
	column-gap: 10px;
}

5.1.6. justify-content

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">A</div>
			<div class="grid-item">B</div>
			<div class="grid-item">C</div>
			<div class="grid-item">D</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: navy;
	border: 1px solid white;
	color: white;
	text-align: center;
}
.grid-container {
	display: grid;
	grid-template-rows: repeat(2, 150px);
	grid-template-columns: repeat(2, 150px);
	justify-content: center;
}

5.1.7. align-content

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">P</div>
			<div class="grid-item">Q</div>
			<div class="grid-item">R</div>
			<div class="grid-item">S</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: silver;
	border: 1px solid white;
	color: white;
	text-align: center;
}
.grid-container {
	display: grid;
	height: 100vh;
	grid-template-rows: repeat(2,100px);
	grid-template-columns: repeat(2,100px);
	justify-content: center;
	align-content: center;
}

5.1.8. place-content

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">P</div>
			<div class="grid-item">Q</div>
			<div class="grid-item">R</div>
			<div class="grid-item">S</div>
		</div>
	</body>
</html>

/* Write your code below */
.grid-item {
	background-color: silver;
	border: 1px solid white;
	color: white;
	text-align: center;
}
.grid-container {
	display: grid;
	height: 100vh;
	grid-template-rows: repeat(2,100px);
	grid-template-columns: repeat(2,100px);
	place-content: end;
}

5.1.9. justify-items

<!doctype html>
<html>
	<head>
		<link href="style.css" rel="stylesheet" />
	</head>
	<body>
		<!-- Write your code below -->
		<div class="grid-container">
			<div class="grid-item">One</div>
			<div class="grid-item">Two</div>
			<div class="grid-item">Three</div>
			<div class="grid-item">Four</div>
		</div>
	</body>
</html>
/* Write your code below */
.grid-item {
	background-color: silver;
	border: 1px solid white;
	color: white;
}
.grid-container {
	display: grid;
	grid-template-rows: repeat(2,100px);
	grid-template-columns: repeat(2,100px);
	background-color: black;
	width: 250px;
	height: 250px;
	row-gap: 30px;
	column-gap: 30px;
	justify-items: end;
}

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.