Home > Mobile >  Fixed navbar hiding page content
Fixed navbar hiding page content

Time:03-10

The navbar is fixed, so when I move to /team. The content of page hides behind the navbar. I tried adding margins but still does not work. Is it possible to add the team component content after the navbar? Here's how it looks

navbar css

nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    min-height: 6vh;
    background-color: white;
    position: fixed;
    width: 100%;
}

Here is the jsx file.

import React from "react";
import "../css/navbar.css";
import { Link } from "react-scroll";
import logo from "../images/logo.png";
import { Link as RouterLink } from "react-router-dom";

const Navbar = () => {
    return (
        <nav>
            <div className="nav-logo">
                <a href="/">
                    <img src={logo} alt="" />
                </a>
            </div>
            <ul className="navlinks">
                <li>
                    <Link smooth={true} to="home">
                        Home
                    </Link>
                </li>
                <li>
                    <Link smooth={true} to="about">
                        About
                    </Link>
                </li>
                <li>
                    <Link smooth={true} to="services">
                        Services
                    </Link>
                </li>
                <li>
                    <a href="/team">Our Team</a>
                </li>
                <li>
                    <a href="/">Jobs</a>
                </li>
                <li>
                    <RouterLink to="/team">Contact Us</RouterLink>
                </li>
            </ul>
        </nav>
    );
};

export default Navbar;

CodePudding user response:

when using a fixed position navbar you should add padding or margin to the section below it or add an empty div with a height:

  margin-top: 30px; // or padding-top: 30px;

add this to the section below the navbar.

CodePudding user response:

When you have a fixed navbar, it's better to define a static height and use this height to define a padding-top on your content.

.yourcontentclass{
    padding-top:6vh;
}
  • Related