Secret message concealed within the depths of my Bootstrap 5 Side Navbar

I have successfully created a side NavBar using Bootstrap 5, but I'm facing an issue where my text is getting hidden behind the navbar. Any suggestions on how I can resolve this?

Below is the code for my side Navbar:

const Navbar = ({ handleClick, isLoggedIn, email }) => (
  <>
    <nav
      className="navbar navbar-expand d-flex flex-column align-item-center-start"
      id="sidebar"
    >
      <a href="/" className="navbar-brand text-light mt-8">
        <div className="display-6 font-weight-bold">
          <span>TESTING</span>
        </div>
      </a>
      <ul className="navbar-nav d-flex flex-column w-100">
        <li className=" h-25 nav-item border-bottom">
          <a href="/" className="nav-link text-light pl-4">
            HOME
          </a>
        </li>

        <li className="h-25  nav-item border-bottom">
          <a href="#" className="nav-link text-light ">
            SEARCH
          </a>
        </li>

        <li className="nav-item h-10 border-bottom">
          <a href="/show" className="nav-link text-light ">
            PODCASTS
          </a>
        </li>

        <li className="nav-item h-25 border-bottom">
          <a href="#" className="nav-link text-light pl-4">
            YOUR LIBRARY
          </a>
        </li>

        <li className="nav-item h-25 border-bottom">
          <a href="/login" className="nav-link text-light pl-4">
            LOGIN
          </a>
        </li>
        <li className="nav-item h-25 border-bottom">
          <a
            href="#"
            onClick={handleClick}
            className="nav-link text-light pl-4"
          >
            LOGOUT
          </a>
        </li>
      </ul>
    </nav>
    {isLoggedIn ? (
      <LoggedInNav
        handleClick={handleClick}
        isLoggedIn={isLoggedIn}
        email={email}
      />
    ) : (
      <div>
        {/* The navbar will show these links before you log in
        <a href="/login">Login(Spotify)</a>
        <Link to="/signup">Sign Up</Link> */}
      </div>
    )}
  </>
);

Here is the CSS I am using:

.navbar {
  width: 210px;
  height: 100vh;
  position: fixed;
  /* margin-left: -300px; */
  background-color: darkgray;
}



Current look of my app can be seen here: https://i.sstatic.net/wiPry.png

While the password form is visible, the username form is obstructed by the navbar. Any guidance on how to improve this would be highly appreciated. Thank you!

Answer №1

When you use position: fixed;, the element is taken out of the normal content flow, allowing it to overlap other elements while being positioned relative to the body.

To display elements side by side, it's recommended to wrap them in a flex container instead of using a fragment.

Check out this example: https://codesandbox.io/s/sharp-mclean-tpropv

/* React */
import "./styles.css";

export default function App() {
  return (
    <div className="wrapper">
      <nav className="nav">Hello World</nav>
      <div className="other">Login Form</div>
    </div>
  );
}

/* CSS */
.wrapper {
  display: flex;
  height: 100vh;
}

.nav {
  width: 210px;
  height: 100vh;
  background-color: darkgray;
}

.other {
  /* ... */
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing HTML to emphasize a section of text

Hey there! I have a question related to an image with unicodes. The letter featured in the image was written using unicode characters పా. I'm trying to highlight the white portion of the image, but simply replacing it with ా isn&apos ...

"Troubleshooting the non-functional :before pseudo-element in a Select-Box

I am having trouble with my CSS. Below is the code I am using: /*Custom Select Box*/ select#user_select { background-color: var(--white); float: right; color: var(--dark_grey); width: 30%; height: 3rem; padding-left: 3%; bord ...

Prevent users from selecting multiple rows in DataGrid using Material UI

I am trying to solve an issue with the Material UI DataGrid where I want to only allow selection of one row at a time in the checkbox section. Currently, when I select a checkbox, multiple rows get selected which is not the desired behavior. I have attempt ...

Mastering React Final Form: Displaying data using a button placed outside the form

I have a query regarding integrating my form component (<InvoiceForm.tsx />) with a button component (<Button.js />) to save its data in the database. The button component is located in another component called <InvoiceList.tsx />, which ...

What is the best way to navigate my Page while my Dialog Component is displayed?

Is there a way to enable scrolling on the background when a dialog component opens up? By default, scrolling is disabled when the dialog appears. How can we allow scrolling in the background? Here is the code snippet: import React, { useState } from &apos ...

HTML formatting for text

I recently created an HTML website using Dreamweaver. I faced an issue while trying to design a section within an article using tables to incorporate both text and images. Unfortunately, the tables did not have rounded edges as I desired. I am reaching out ...

Is there a way to exclude the Unicode character from the first menu item while still utilizing it in the other items on my menu?

I have been working on customizing my menu by using the unicode character \25C6 to represent a black solid diamond as a spacer between labels. After searching for solutions on Stack Overflow, I attempted to implement the suggested method using the bef ...

The link in the NextJs app is currently appending to the current path, but I would prefer it

Imagine the current url is: localhost:3000/foo/hello, with hello being a dynamic route. There's a Link Component with href={'/something/test'}. Upon clicking it, the goal is to land on: localhost:3000/something/test, where test is another dy ...

[Babel]: The option foreign.Children is not recognized

I encountered an error while building with the following script: webpack --colors --progress --watch --config --jsx-loader webpack.config.js Below is the content of my package.json file: { "dependencies": { // List of dependencies here }, "dev ...

Unable to retrieve the image

When trying to fetch an image, I encountered the following error: Failed to load resource: the server responded with a status of 404 (Not Found) TopBar.jsx import { useContext } from "react"; import { Link } from "react-router-dom"; ...

React state object iteration doesn't produce any visible output

Trying to dynamically showcase checkboxes with starting values from the state using Material-UI for UI components. tagState: { All: true, Pizza: false, Breakfast: false, Chicken: false } Utilized Object entries and forEach to generate checkbox ...

Can React be integrated with Material UI within the PHP framework?

I recently started learning to code and I'm eager to incorporate ReactJS into my PHP projects. When including React on a different website, you can simply add script tags to load React into it. <script src="https://unpkg.com/react-dom@16/u ...

Struggling with integrating Material UI radio buttons into Formik Part Two

Some time ago, I sought help on integrating radio buttons with Material UI and Formik in this thread: Cannot get Material UI radio buttons to work with Formik. Despite receiving a solution, it unfortunately didn't resolve the issue in our specific app ...

The React front-end struggles to display MongoDB entries and eventually times out after 10 seconds

I am experiencing an issue where my React front-end is unable to fetch details from a MongoDB database and I need assistance debugging the problem. The back-end utilizes a serverless function. Each time I reload the page, my React code fails to locate the ...

Have I incorrectly implemented responsiveness on my website?

I created my HTML using Bootstrap 3.3.7: <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="copyright" content= ...

Pictures are automatically adjusted to a resolution of 0 x 0 within the Heroku application

I have encountered an issue with my simple webpage hosted on Heroku. Despite appearing perfectly fine on localhost, 4 images are automatically resized to 0x0 when viewed on Heroku. I am struggling to identify the cause of this problem. Here is how it appe ...

"Utilize input within the div element to occupy the entire cell of the

There is a form input enclosed within a div which is nested inside a table cell. <td align="left" id="subformAttachments_Htmltable1td10" style="border:solid 1px black;width:316px;" class="tbldroppable ui-droppable ...

Is it possible to toggle between thumbnails and a larger image in a jQuery gallery?

Hello, I am new to website development and I would like to create a jquery based photo gallery for my personal website. One feature that really catches my eye is this one (for example): The gallery has a large thumbnail grid where you can click on a thumb ...

What is the best way to create rounded corners on a WordPress login page?

I recently implemented the Custom Login Page Customizer plugin on my WordPress website and it has created a beautiful login page. While I was able to round the corners of my logo using CSS, I'm struggling to achieve the same effect on the login form. ...

What is the best method for implementing border-radius on select2 elements?

I previously had a default bootstrap user select box with a border-radius style applied: <div class="container"> <select class="form-control" style="border-radius: 1rem;"> <option value="1">Us ...