Day 1: Add CSS Only Soluition

This commit is contained in:
2021-04-09 18:29:20 +02:00
parent 3efc794d75
commit b591904038
3 changed files with 146 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous" /> -->
<link rel="stylesheet" href="style.css" />
<title>Day 1 - Expanding Cards</title>
</head>
<body>
<div class="container">
<input type="radio" name="images" id="img-01" class="img-toggle" />
<label
for="img-01"
class="panel"
style="
background-image: url(https://images.unsplash.com/photo-1508672019048-805c876b67e2?w=1350);
"
>
<h3>Explore The World</h3>
</label>
<input type="radio" name="images" id="img-02" class="img-toggle" />
<label
for="img-02"
class="panel"
style="
background-image: url(https://images.unsplash.com/photo-1485123263479-f5ea30a2f92d?w=1350);
"
>
<h3>Winter in Sweden</h3>
</label>
<input type="radio" name="images" id="img-03" class="img-toggle" />
<label
for="img-03"
class="panel"
style="
background-image: url(https://images.unsplash.com/photo-1585392569893-c33ab1e3f3f5?w=1350);
"
>
<h3>Summer in Australia</h3>
</label>
<input type="radio" name="images" id="img-04" class="img-toggle" />
<label
for="img-04"
class="panel"
style="
background-image: url(https://images.unsplash.com/photo-1534430480872-3498386e7856?w=1350);
"
>
<h3>New York</h3>
</label>
<input type="radio" name="images" id="img-05" class="img-toggle" />
<label
for="img-05"
class="panel"
style="
background-image: url(https://images.unsplash.com/photo-1552465011-b4e21bf6e79a?w=1350);
"
>
<h3>South East Asia</h3>
</label>
</div>
<script src="script.js"></script>
</body>
</html>

View File

View File

@@ -0,0 +1,72 @@
@import url("https://fonts.googleapis.com/css2?family=Muli&display=swap");
* {
box-sizing: border-box;
}
body {
font-family: "Muli", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
.container {
display: flex;
width: 90vw;
}
.panel {
background-size: auto 100%;
background-position: center;
background-repeat: no-repeat;
height: 80vh;
border-radius: 50px;
color: #fff;
cursor: pointer;
flex: 0.5;
margin: 10px;
position: relative;
transition: flex 0.7s ease-in;
}
.panel h3 {
font-size: 24px;
position: absolute;
bottom: 20px;
left: 20px;
margin: 0;
opacity: 0;
transition: opacity 0.4s ease-in;
}
.panel.active {
flex: 5;
}
.img-toggle {
display: none;
}
.img-toggle:checked + .panel {
flex: 5;
}
.img-toggle:checked + .panel h3 {
opacity: 1;
transition: opacity 0.5s ease-in 0.2s;
}
@media (max-width: 480px) {
.container {
width: 100vw;
}
.panel:nth-of-type(4),
.panel:nth-of-type(5) {
display: none;
}
}