Skip to content

Commit 78870b0

Browse files
committed
Positions, Float, Media Queries - ::before and ::after Example
1 parent ad6b44c commit 78870b0

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
</head>
1212

1313
<body>
14-
<p>I'm extremely simple</p>
14+
<div>
15+
<img src="./big.jpeg" alt="big-retro" />
16+
</div>
1517
</body>
1618
</html>

styles.css

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,47 @@ content:'' - required
44
img --- does not work
55
*/
66

7-
p::before {
8-
content: "hello world";
9-
font-size: 2rem;
10-
color: blue;
11-
font-weight: 700;
7+
div {
8+
width: 70vw;
9+
/* border: 3px solid red; */
10+
margin: 100px auto;
11+
position: relative;
12+
}
13+
14+
img {
15+
width: 100%;
1216
display: block;
13-
background: yellow;
1417
}
1518

16-
p::after {
19+
div::before {
1720
content: "";
18-
font-size: 1rem;
19-
color: red;
20-
font-weight: 700;
21-
background: greenyellow;
22-
display: block;
21+
border: 2px solid grey;
22+
box-sizing: border-box;
23+
width: 100%;
24+
height: 100%;
25+
position: absolute;
26+
top: -40px;
27+
left: -40px;
28+
z-index: -2;
29+
transition: all 0.5s linear;
30+
}
31+
32+
div::after {
33+
content: "";
34+
background: rgba(128, 128, 128, 0.5);
35+
/* background: grey; */
36+
box-sizing: border-box;
2337
width: 100%;
24-
height: 3rem;
38+
height: 100%;
39+
position: absolute;
40+
top: -20px;
41+
left: -20px;
42+
z-index: -1;
43+
transition: all 0.5s linear;
44+
}
45+
46+
div:hover::before,
47+
div:hover::after {
48+
top: 0;
49+
left: 0;
2550
}

0 commit comments

Comments
 (0)