Skip to content

Commit 7da2e23

Browse files
committed
position examples
1 parent cb9aef2 commit 7da2e23

File tree

6 files changed

+284
-1
lines changed

6 files changed

+284
-1
lines changed

learn/tasks/float/marking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Floats Marking Guide
22

3-
The aim of the tasks are to demonstrate an understanding of the properties covered in the [Float](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Backgrounds_and_borders) lesson in Learn Web Development on MDN.
3+
The aim of the tasks are to demonstrate an understanding of the properties covered in the [Float](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Floats) lesson in Learn Web Development on MDN.
44

55
## Task 1
66

learn/tasks/position/marking.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Floats Marking Guide
2+
3+
The aim of the tasks are to demonstrate an understanding of the properties covered in the [Float](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning) lesson in Learn Web Development on MDN.
4+
5+
## Task 1
6+
7+
This task covers understanding of `position: relative` and `position: absolute` and how they relate to each other in terms of relative positioning creating a new positioning context.
8+
9+
```
10+
.container {
11+
position: relative;
12+
}
13+
14+
.target {
15+
position: absolute;
16+
top: 0;
17+
right: 0;
18+
}
19+
```
20+
21+
A likely issue will be that the student adds `position: absolute` to the child but does not apply `position: relative` to the container. In that case the target will end up being positioned according to the viewport.
22+
23+
For the extra task, the student needs to add a negative `z-index` to the target, for example `z-index:2`.
24+
25+
## Task 2
26+
27+
In task 2 we check understanding of `position: fixed` with a slightly different example to that in the materials using a sidebar.
28+
29+
```
30+
.sidebar {
31+
position: fixed;
32+
}
33+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Position: Task 1</title>
6+
<style>
7+
body {
8+
background-color: #fff;
9+
color: #333;
10+
font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
11+
padding: 1em;
12+
margin: 0;
13+
}
14+
* {
15+
box-sizing: border-box;
16+
}
17+
.container {
18+
width: 500px;
19+
padding: 0.5em;
20+
border: 5px solid #ccc;
21+
}
22+
.target {
23+
width: 150px;
24+
height: 150px;
25+
border-radius: 5px;
26+
background-color: rgb(207,232,220);
27+
padding: 1em;
28+
}
29+
</style>
30+
31+
</head>
32+
33+
<body>
34+
35+
<div class="container">
36+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
37+
<div class="target">Target</div>
38+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
39+
</div>
40+
41+
</body>
42+
43+
</html>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Position: Task 1</title>
6+
<link rel="stylesheet" href="../styles.css" />
7+
<style>
8+
* {
9+
box-sizing: border-box;
10+
}
11+
.container {
12+
width: 500px;
13+
padding: .5em;
14+
border: 5px solid #ccc;
15+
}
16+
.target {
17+
width: 150px;
18+
height: 150px;
19+
border-radius: 5px;
20+
background-color: rgb(207,232,220);
21+
padding: 1em;
22+
}
23+
</style>
24+
25+
<style class="editable">
26+
.container {
27+
28+
}
29+
30+
.target {
31+
32+
}
33+
</style>
34+
</head>
35+
36+
<body>
37+
<section class="preview">
38+
<div class="container">
39+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
40+
<div class="target">Target</div>
41+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
42+
</div>
43+
44+
</section>
45+
46+
<textarea class="playable playable-css" style="height: 220px;">
47+
.container {
48+
49+
}
50+
51+
.target {
52+
53+
}
54+
</textarea>
55+
56+
<textarea class="playable playable-html" style="height: 130px;">
57+
<div class="container">
58+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
59+
<div class="target">Target</div>
60+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
61+
</div>
62+
</textarea>
63+
64+
<div class="playable-buttons">
65+
<input id="reset" type="button" value="Reset" />
66+
</div>
67+
</body>
68+
<script src="../playable.js"></script>
69+
</html>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Position: Task 2</title>
6+
<style>
7+
body {
8+
background-color: #fff;
9+
color: #333;
10+
font: 1.2em / 1.5 Helvetica Neue, Helvetica, Arial, sans-serif;
11+
padding: 1em;
12+
margin: 0;
13+
}
14+
* {
15+
box-sizing: border-box;
16+
}
17+
.container {
18+
width: 550px;
19+
height: 400px;
20+
padding: .5em;
21+
border: 5px solid #ccc;
22+
overflow: auto;
23+
}
24+
.sidebar {
25+
background-color: rgb(207,232,220);
26+
padding: 1em;
27+
float: left;
28+
width: 150px;
29+
}
30+
.content {
31+
padding: 1em;
32+
margin-left: 160px;
33+
}
34+
</style>
35+
36+
37+
</head>
38+
39+
<body>
40+
41+
<div class="container">
42+
<div class="sidebar">
43+
<p>This is the sidebar. It should remain in position as the content scrolls.</p>
44+
</div>
45+
<div class="content">
46+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
47+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
48+
<p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke.</p>
49+
</div>
50+
</div>
51+
52+
</body>
53+
54+
</html>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Position: Task 2</title>
6+
<link rel="stylesheet" href="../styles.css" />
7+
<style>
8+
* {
9+
box-sizing: border-box;
10+
}
11+
.container {
12+
width: 550px;
13+
height: 400px;
14+
padding: .5em;
15+
border: 5px solid #ccc;
16+
overflow: auto;
17+
}
18+
.sidebar {
19+
background-color: rgb(207,232,220);
20+
padding: 1em;
21+
float: left;
22+
width: 150px;
23+
}
24+
.content {
25+
padding: 1em;
26+
margin-left: 160px;
27+
}
28+
</style>
29+
30+
<style class="editable">
31+
.container {
32+
33+
}
34+
35+
.sidebar {
36+
37+
}
38+
</style>
39+
</head>
40+
41+
<body>
42+
<section class="preview">
43+
<div class="container">
44+
<div class="sidebar">
45+
<p>This is the sidebar. It should remain in position as the content scrolls.</p>
46+
</div>
47+
<div class="content">
48+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
49+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
50+
<p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke.</p>
51+
</div>
52+
</div>
53+
54+
</section>
55+
56+
<textarea class="playable playable-css" style="height: 220px;">
57+
.container {
58+
59+
}
60+
61+
.sidebar {
62+
63+
}
64+
</textarea>
65+
66+
<textarea class="playable playable-html" style="height: 500px;">
67+
<div class="container">
68+
<div class="sidebar">
69+
<p>This is the sidebar. It should remain in position as the content scrolls.</p>
70+
</div>
71+
<div class="content">
72+
<p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
73+
<p>Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.</p>
74+
<p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke.</p>
75+
</div>
76+
</div>
77+
</textarea>
78+
79+
<div class="playable-buttons">
80+
<input id="reset" type="button" value="Reset" />
81+
</div>
82+
</body>
83+
<script src="../playable.js"></script>
84+
</html>

0 commit comments

Comments
 (0)