Unable to showcase information in the center of an HTML document

Hello, I'm facing an issue with my HTML page that has a left vertical nav-bar. Despite my efforts, I can't seem to display content (text) in the center of the page as shown in the screenshot with the red oval.

I've attempted inserting text in various places like between every <div> tag on the page and at the beginning or end of the <body> section, but unfortunately, none of these methods have worked.

/* Custom styles */

.navbar {
  height: 100vh;
  /* Make navbar take full height of the viewport */
  width: 250px;
  /* Set a fixed width for the navbar */
}

.navbar-nav {
  flex-direction: column;
  /* Stack items vertically */
}

.nav-item {
  width: 100%;
  /* Make nav items take full width of the navbar */
}

.nav-link {
  border: 1px solid black;
  /* Add border to the nav items */
  background-color: white;
  /* Set background color for the nav items */
  color: black;
  /* Set text color for the nav items */
  padding: 10px;
  /* Add padding inside the nav items */
  margin: 5px 0;
  /* Add some space between the nav items */
  border-radius: 0;
  /* Remove border radius to match the screenshot */
}


/* Adjust the active link style */

.nav-link.active,
.nav-link:focus,
.nav-link:hover {
  background-color: #e9ecef;
  /* Change background color for active/hover/focus */
  color: black;
  /* Text color for active/hover/focus */
}


/* Remove default Bootstrap styles for active nav-link */

.nav-link.active {
  border-color: #e9ecef;
  background-color: #e9ecef;
}
<!-- Include Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css" rel="stylesheet">


<div class="d-flex flex-column flex-shrink-0 p-3 bg-light" style="width: 280px;">

  <a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none">
    <span class="fs-4">Peeps</span>
  </a>
  <hr>
  <ul class="nav nav-pills flex-column mb-auto">
    <li class="nav-item">
      <a href="#" class="nav-link active" aria-current="page">
              Home
            </a>
    </li>
    <li>
      <a href="#" class="nav-link link-dark">
              Org Chart
            </a>
    </li>
    <li>
      <a href="#" class="nav-link link-dark">
              OKRs
            </a>
    </li>
    <li>
      <a href="#" class="nav-link link-dark">
              Performance
            </a>
    </li>
    <li>
      <a href="#" class="nav-link link-dark">
              Onboarding
            </a>
    </li>
    <li>
      <a href="#" class="nav-link link-dark">
              Learning & Development
            </a>
    </li>
  </ul>
  <hr>
  <div class="dropdown">

    <a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
      <strong>More</strong>
    </a>
    <ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
      <li><a class="dropdown-item" href="#">New project...</a></li>
      <li><a class="dropdown-item" href="#">Settings</a></li>
      <li><a class="dropdown-item" href="#">Profile</a></li>
      <li>
        <hr class="dropdown-divider">
      </li>
      <li><a class="dropdown-item" href="#">Sign out</a></li>
    </ul>
  </div>

</div>

<div class="container mt-3">

  <div class="row">

    <div class="col-12 mb-3">

      <div class="p-3 box">

        <h2>Welcome to Peeps!</h2>
      </div>
    </div>
    <div class="col-md-6">

      <div class="p-3 box">
        <p>Recommendations on how to get started go here.</p>
      </div>
    </div>
    <div class="col-md-6">

      <div class="p-3 box">
        <p>Some relevant graphs will go here. This will likely be around employee data, and would be customizable. --></p>
      </div>
    </div>
  </div>
</div>

<!-- Include Bootstrap JS and its dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89b978a9db8cad6cdd6cb">[email protected]</a>/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"></script>

1

Answer №1

To align the container content with your oval, simply add a flex property to the body element.

<!DOCTYPE html>
<html lang="en>

<head>
  <meta charset="UTF-8>
  <meta name="viewport" content="width=device-width, initial-scale=1.0>
  <title>Home Page</title>
  <!-- Include Bootstrap CSS -->
  <link href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css" rel="stylesheet>
  <style>
    /* Custom styles */
    
    .navbar {
      height: 100vh;
      /* Make navbar take full height of the viewport */
      width: 250px;
      /* Set a fixed width for the navbar */
    }
    
    .navbar-nav {
      flex-direction: column;
      /* Stack items vertically */
    }
    
    .nav-item {
      width: 100%;
      /* Make nav items take full width of the navbar */
    }
    
    .nav-link {
      border: 1px solid black;
      /* Add border to the nav items */
      background-color: white;
      /* Set background color for the nav items */
      color: black;
      /* Set text color for the nav items */
      padding: 10px;
      /* Add padding inside the nav items */
      margin: 5px 0;
      /* Add some space between the nav items */
      border-radius: 0;
      /* Remove border radius to match the screenshot */
    }
    /* Adjust the active link style */
    
    .nav-link.active,
    .nav-link:focus,
    .nav-link:hover {
      background-color: #e9ecef;
      /* Change background color for active/hover/focus */
      color: black;
      /* Text color for active/hover/focus */
    }
    /* Remove default Bootstrap styles for active nav-link */
    
    .nav-link.active {
      border-color: #e9ecef;
      background-color: #e9ecef;
    }
  </style>
</head>

<body class="d-flex">

  <div class="d-flex flex-column flex-shrink-0 p-3 bg-light" style="width: 280px">

    <a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none">
      <span class="fs-4">Peeps</span>
    </a>
    <hr>
    <ul class="nav nav-pills flex-column mb-auto">
      <li class="nav-item">
        <a href="#" class="nav-link active" aria-current="page">
              Home
            </a>
      </li>
      <li>
        <a href="#" class="nav-link link-dark">
              Org Chart
            </a>
      </li>
      <li>
        <a href="#" class="nav-link link-dark">
              OKRs
            </a>
      </li>
      <li>
        <a href="#" class="nav-link link-dark">
              Performance
            </a>
      </li>
      <li>
        <a href="#" class="nav-link link-dark">
              Onboarding
            </a>
      </li>
      <li>
        <a href="#" class="nav-link link-dark">
              Learning & Development
            </a>
      </li>
    </ul>
    <hr>
    <div class="dropdown">

      <a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
        <strong>More</strong>
      </a>
      <ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
        <li><a class="dropdown-item" href="#">New project...</a></li>
        <li><a class="dropdown-item" href="#">Settings</a></li>
        <li><a class="dropdown-item" href="#">Profile</a></li>
        <li>
          <hr class="dropdown-divider">
        </li>
        <li><a class="dropdown-item" href="#">Sign out</a></li>
      </ul>
    </div>

  </div>

  <div class="container mt-3">

    <div class="row">

      <div class="col-12 mb-3">

        <div class="p-3 box">

          <h2>Welcome to Peeps!</h2>
        </div>
      </div>
      <div class="col-md-6">

        <div class="p-3 box">
          <p>Recommendations on how to get started go here.</p>
        </div>
      </div>
      <div class="col-md-6">

        <div class="p-3 box">
          <p>Some relevant graphs will go here. This will likely be around employee data, and would be customizable. --></p>
        </div>
      </div>
    </div>
  </div>

  <!-- Include Bootstrap JS and its dependencies -->
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0a3afb2a580f2eef5eef3">[email protected]</a>/dist/umd/popper.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"></script>
</body>

</html>

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

Access Vuex Getters in a separate JavaScript file

Within the file /store/user/getters.js: function getLoggedIn (state) { return state.loggedIn } In a different file, router-auth.js, I attempted to access the value (true or false) of getters.getLoggedIn in the following manner: import user from '.. ...

Error 400: The onCreate Trigger function for Cloud functions is experiencing issues with HTTP requests due to errors in the request

I am encountering an issue when attempting to add a trigger for Firestore OnCreate, as the deployment fails with HTTP Error: 400 stating that the request has errors. Essentially, my goal is to write to a new document if a record is created in a different ...

Is there a way to embed an AJAX submit form into a notification without the need for page refresh?

I have integrated the jQuery plugin toastr js () for notifications on my website. I am facing an issue where I want to include a contact form within the notification popup and submit it using AJAX. Despite having the form working fine outside of the toastr ...

The error message indicates that the argument cannot be assigned to the parameter type 'AxiosRequestConfig'

I am working on a React app using Typescript, where I fetch a list of items from MongoDB. I want to implement the functionality to delete items from this list. The list is displayed in the app and each item has a corresponding delete button. However, when ...

Issues with rendering AngularJS onto an HTML page are currently being experienced

I was attempting to learn AngularJs in order to improve my front-end development skills, but unfortunately I ran into some issues. Despite following the video tutorials on their site step by step, I couldn't get it to render correctly. Here's the ...

Is the displayed Cyrillic string in the incorrect character set?

I am facing an issue with extracting a value from a decoded JSON response obtained from a Russian API. The value within the JSON = Object268 Initially, it appeared as: Объект 268 After including <meta charset="utf-8"> in my html ...

Node.js: Obtain the type of file

Hey everyone, I am currently working on a project in Node.js where I need to extract the file type. This is necessary as I have to rename the file before uploading it for version control and then perform some processing tasks on it. Although I know that c ...

The `process` variable is not recognized in a Vue/TypeScript component

I've encountered an issue trying to use .env variables in my Vue app. When I ran npm install process, the only syntax that didn't result in an error when importing was: import * as process from 'process'; Prior to this, I received the ...

Creating a responsive navbar with a custom width form

Just started working with bootstrap and playing around with some new UI concepts. I'm having an issue with a non-responsive form width within my navbar, even though the navbar itself is responsive. I've tried using different collapse classes, but ...

Preserve present condition following a jQuery click event

I'm facing a challenge where I need to hide a button upon clicking another button, but the problem is that when the page refreshes, the hidden button becomes visible again. My objective is to keep it hidden even after refreshing the page and only reve ...

The redirection from Azure AD SSO is not working properly following a logout

In my quest to integrate Azure AD login into a single-page application built with ReactJS, I utilized the MSAL React package. While successfully implementing the login functionality, I encountered an issue during logout where I found myself unable to redir ...

What is the process for importing npm scoped packages with @ symbol in Deno?

Having some trouble with importing @whiskeysockets/baileys in Deno. Here's the code snippet I'm using: import * as a from "npm:@whiskeysockets/baileys"; console.log(a); When I try to run deno run main.ts, it throws the following error: ...

"Successfully rendering the map on the initial load, but encountering an error of 'cannot map undefined'

Having trouble displaying data retrieved from an API. Initially, the movie titles are shown without any issues. However, upon refreshing the page, an error message stating "cannot map undefined" appears. Here is the code snippet: const [media, set ...

The URL redirect is malfunctioning and prompting an error stating "No 'Access-Control-Allow-Origin' header"

Having trouble sending an Ajax request to a Node.js server from my application and encountering the following error: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the ...

Angular 2 - Error: Regular expression missing forward slash syntax

Recently, I began working on an Angular 2 tutorial app using this repository. While I can successfully launch the app and display static content, I am facing challenges with rendering dynamic content from the component. I have a feeling that the error migh ...

The AJAX call was successful with a return code of 200, however an error

HTML code snippet: <a href="javascript:void(0)" onclick="$.join_group(<?=$USER_ID?>, <?=$groups[$i]["id"]?>)"><?=$language["join"]?></a> JavaScript function: $.join_group = function(user_id, group_id) { var input = "u ...

Struggling to incorporate blocks into Jade for Express. Encountering errors like "Max Stack Size Exceeded" and issues with setHeader

I am currently using Express along with a simple express-generator server that I created. My first task was to focus on creating the view layout and extending the index page, but unfortunately, I have encountered some challenges. Throughout my process, I& ...

Tips for positioning a grid at the center of a MaterialUI layout

I am struggling to position 3 paper elements in the center of both the vertical and horizontal axes on the screen. Despite applying various CSS rules and properties, the height of the HTML element consistently shows as 76 pixels when inspected in the con ...

Rapidly verifying PHP arrays with jQuery/AJAX

I am looking for a way to validate values within a PHP array in real-time without the need to click a submit button by utilizing jQuery/AJAX. As users type an abbreviation into a text field, I want to instantly display whether the brand exists (either v ...

switching back and forth between the registration and login forms

<script> $(document).ready(function(){ $("#register_link").click(function() { $("#login_or_register").empty(); $("#login_or_register").load("register_form.php"); }); $("#login_link").click(function() { $("# ...