Skip to content

Commit 226ccf2

Browse files
committed
Positions, Float, Media Queries - Inset Property
1 parent 78870b0 commit 226ccf2

File tree

2 files changed

+22
-41
lines changed

2 files changed

+22
-41
lines changed

index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
</head>
1212

1313
<body>
14-
<div>
15-
<img src="./big.jpeg" alt="big-retro" />
14+
<div class="box">regular box</div>
15+
<div class="box special">
16+
<h1>special</h1>
1617
</div>
1718
</body>
1819
</html>

styles.css

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,30 @@
1-
/*
2-
::before ::after pseudo-elements creates element and inserts before and after CONTENT
3-
content:'' - required
4-
img --- does not work
1+
/* The inset CSS property is a shorthand
2+
that corresponds to the top, right, bottom,left properties.
53
*/
64

7-
div {
8-
width: 70vw;
9-
/* border: 3px solid red; */
10-
margin: 100px auto;
11-
position: relative;
5+
* {
6+
margin: 0;
127
}
138

14-
img {
15-
width: 100%;
16-
display: block;
9+
.box {
10+
background: orange;
11+
width: 300px;
12+
height: 300px;
13+
margin-bottom: 1rem;
1714
}
1815

19-
div::before {
20-
content: "";
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;
16+
.special {
17+
position: relative;
3018
}
3119

32-
div::after {
33-
content: "";
34-
background: rgba(128, 128, 128, 0.5);
35-
/* background: grey; */
36-
box-sizing: border-box;
37-
width: 100%;
38-
height: 100%;
20+
.special h1 {
21+
background: rgba(0, 0, 0, 0.5);
3922
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;
23+
/* top: 0;
4924
left: 0;
25+
bottom: 0;
26+
right: 0; */
27+
inset: 0;
28+
text-align: center;
29+
color: white;
5030
}

0 commit comments

Comments
 (0)