Bring the navbar text to the center of the screen in CSS

  • Context: HTML/CSS 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Center Css Screen Text
Click For Summary
SUMMARY

The discussion focuses on centering navbar text using CSS in a web project. The user initially attempted to use "display: flex; justify-content: center;" but found it ineffective. The solution provided involves modifying the class from "me-auto" to "mx-auto" within the

    element, which effectively centers the navbar items. This adjustment leverages Bootstrap's utility classes for proper alignment.

    PREREQUISITES
    • Understanding of CSS Flexbox properties
    • Familiarity with Bootstrap framework and its utility classes
    • Basic knowledge of HTML structure and elements
    • Experience with responsive web design principles
    NEXT STEPS
    • Explore Bootstrap's Flexbox utilities for layout management
    • Learn about CSS Grid for advanced layout techniques
    • Investigate responsive design practices using media queries
    • Review CSS best practices for navbar design and accessibility
    USEFUL FOR

    Web developers, frontend designers, and anyone looking to enhance their skills in CSS layout techniques and Bootstrap framework usage.

shivajikobardan
Messages
637
Reaction score
54
TL;DR
Bring navbar at center CSS
https://demo.w3layouts.com/demos_ne...a-liberty-demo_Free/2002651968/web/index.html

This is the website that I am trying to build.

This is my current navbar.
fJLX3O3apC1PU0tIIH_EzdnGbwUqeLO7jmg5P_T2pLgmUUVb1Q.png


This is what I want to build.
wN-ub_JJv8XmNqoUbNsD4eCY6JQKuQ-EB2rZ-PJy94XDB9yulA.png

My focus is on "Home" to "Contact". I want to put it at the center of the page like in the second one. My guess was to do display:flex justify-content: center. But it didn't work.
Please guide me how to make it work?

Here's the codepen.
 
Technology news on Phys.org
Increase the value here:
CSS:
.collapse {
  margin-left: 25%;
}

Or, better, remove the previous value and modify the following:
HTML:
<ul class="navbar-nav me-auto  ">
to:
HTML:
<ul class="navbar-nav mx-auto  ">

(That is how it is done in your link)

Can you identify what CSS rules change in this process?
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K