Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed the navbar positioning, as well as overlapping issues #208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<img src="./assets/asset 1.png" alt="company logo">
</a>
<div class="nav-links" id="nav-links">
<ul class="flex">
<ul class="flex navabar-tabs">
<li><a href="#" class="hover-link">Products</a></li>
<li><a href="#" class="hover-link">Customer</a></li>
<li><a href="#" class="hover-link">Pricing</a></li>
Expand Down Expand Up @@ -247,12 +247,30 @@ <h4>Resources</h4>
<script>
const toggleButton = document.getElementById('nav-toggle');
const navLinks = document.getElementById('nav-links');
// const navbartabs = document.getElementById('navbar-tabs');
// console.log(navbartabs);


toggleButton.addEventListener('click', () => {
navLinks.style.width = '100vw';
navLinks.classList.toggle('active');
})
});

window.addEventListener('scroll',function() {
var topBanner = document.querySelector('.top-banner');
var topBannerH = topBanner.offsetHeight;
var navBar = document.querySelector('.main-nav');

if(window.scrollY >= topBannerH){
console.log('should move to the top');
navBar.classList.add('main-nav-sticky');
}
else{
navBar.classList.remove('main-nav-sticky');
}
});

</script>

</body>
</html>
</html>
34 changes: 25 additions & 9 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ul {
list-style: none;
}


/* utility classes */

.small-bold-text {
Expand Down Expand Up @@ -116,6 +117,7 @@ ul {
background-image: url('asset\ 30.png');
background-color: #4fb3d4;
background-size: 300px;
height:50px;
}

.banner-text {
Expand All @@ -125,18 +127,20 @@ ul {
}

/* nav bar */

.main-nav {
margin-top: 40px;
justify-content: space-between;
position:flex;
min-width:100vw;
background-color: #ccc;
transition: all 0.3s ease;
}

position: fixed;
top: 0;
width: 100%;
padding: 10px 0;
margin-left: 50px;

background-color: #ccc
.main-nav-sticky{
position:fixed;
top:0;
left:0;
right:0;
z-index: 1000;
}

.company-logo img {
Expand Down Expand Up @@ -197,6 +201,7 @@ ul {
@media screen and (max-width: 768px) {
.nav-links {
display: none;
width: 100vw;
}

.nav-toggle {
Expand All @@ -206,12 +211,22 @@ ul {
.nav-links.active {
display: block;
}

.nav-links ul{
display:flex;
flex-direction: column;
align-items: flex-start;
padding: 0;
margin: 0;
list-style: none;
}
}


/* header section */

header {
/* margin-top: 30px; */
padding: 50px var(--padding-inline-section) 0;
}

Expand Down Expand Up @@ -277,6 +292,7 @@ header {
justify-content: space-between;
gap: 20px;
margin-top: 20px;
margin-bottom: 20px;
}

.features-card {
Expand Down