Skip to content

Commit

Permalink
completed mtn
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 12, 2021
1 parent 7ebf37b commit a99f90d
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Day 38 - Mobile Tab Navigation/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const contents = document.querySelectorAll(".content");
const listItems = document.querySelectorAll("nav ul li");

listItems.forEach((item, idx) => {
item.addEventListener("click", () => {
hideAllContents();
hideAllItems();

item.classList.add("active");
contents[idx].classList.add("show");
});
});

function hideAllContents() {
contents.forEach((content) => content.classList.remove("show"));
}

function hideAllItems() {
listItems.forEach((item) => item.classList.remove("active"));
}
74 changes: 74 additions & 0 deletions Day 38 - Mobile Tab Navigation/index.html
Original file line number Diff line number Diff line change
@@ -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
href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap"
rel="stylesheet"
/>
<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"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="./style.css" />
<title>Mobile Tab Navigation</title>
</head>
<body>
<div class="phone">
<img
src="https://images.unsplash.com/photo-1480074568708-e7b720bb3f09?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=753&q=80"
alt="home"
class="content show"
/>

<img
src="https://images.unsplash.com/photo-1497493292307-31c376b6e479?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=751&q=80"
alt="work"
class="content"
/>

<img
src="https://images.unsplash.com/photo-1471107340929-a87cd0f5b5f3?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=666&q=80"
alt="blog"
class="content"
/>

<img
src="https://images.unsplash.com/photo-1596524430615-b46475ddff6e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=750&q=80"
alt="about"
class="content"
/>

<nav>
<ul>
<li class="active">
<i class="fas fa-home"></i>
<p>Home</p>
</li>

<li>
<i class="fas fa-box"></i>
<p>Work</p>
</li>

<li>
<i class="fas fa-book-open"></i>
<p>Blog</p>
</li>

<li>
<i class="fas fa-users"></i>
<p>About</p>
</li>
</ul>
</nav>
</div>

<script src="./app.js"></script>
</body>
</html>
75 changes: 75 additions & 0 deletions Day 38 - Mobile Tab Navigation/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: rgba(155, 89, 182, 0.7);
font-family: "Open Sans", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}

.phone {
position: relative;
overflow: hidden;
border: 3px solid #eee;
border-radius: 15px;
height: 450px;
width: 270px;
}

.phone .content {
opacity: 0;
object-fit: cover;
position: absolute;
top: 0;
left: 0;
height: calc(100% - 40px);
width: 100%;
transition: opacity 0.4s ease;
}

.phone .content.show {
opacity: 1;
}

nav {
position: absolute;
bottom: 0;
left: 0;
margin-top: -5px;
width: 100%;
}

nav ul {
background-color: #fff;
display: flex;
list-style-type: none;
padding: 0;
margin: 0;
height: 60px;
}

nav li {
color: #777;
cursor: pointer;
flex: 1;
padding: 10px;
text-align: center;
}

nav ul li p {
font-size: 12px;
margin: 2px 0;
}

nav ul li:hover,
nav ul li.active {
color: #8e44ad;
}

0 comments on commit a99f90d

Please sign in to comment.