question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making navbar width consistent with the main layout on large displays

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Description

  • On large displays, the navbar’s width isn’t matched to the main content, footer, and it expands to the edges of the screen making it easy to miss the navbar’s contents. (demonstrating the issue on docusaurus.io below in screenshot)

  • However, if max-width and justify-content are applied, it makes the navbar more consistent with the rest of the design.

  • I’ve added the following to my custom.css, and it seems to be working

.navbar {
	justify-content: center;
}

.navbar__inner {
	max-width: var(--ifm-container-width-xl);
}
  • Should this be Docusaurus’ default behavior?

Issue

docusaurus(iMac) - Issue


Suggested Change

docusaurus(iMac) - Suggestion

Has this been requested on Canny?

No response

Motivation

  • On large displays, with main body having a max width, it’s looks a bit out of place to have the menu items at the edges, and not have the navbar as the same width as the rest of the content.

  • When the nabar is the same max width as the content area, you don’t need to scan the entire width of the screen. The entire page stays a vertical scannable area. For ex. https://developer.apple.com/documentation/Xcode/Xcode-Cloud

API design

No response

Have you tried building it?

No response

Self-service

  • I’d be willing to contribute this feature to Docusaurus myself.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
LichLord91commented, Jul 6, 2022

Looking at https://theochu.com and reading the css in dev tools. I like the solution he came up with. Seems to work great on mobile/full screen and with collapsible button.

@media (min-width: 1416px) {
	.main-wrapper {
		align-self: center;
		max-width: 1400px;
		width: 1400px;
	}
}

.navbar .navbar__inner {
    margin: 0 auto;
    max-width: 1360px;
}

image

2reactions
jetxrcommented, Jun 9, 2022

Adding a max-width and margin: auto to main-wrapper seemed to work. Not sure if it’s the best way to do it. Also, new to Docusaurus, so I don’t know if this will have an effect on something else. Maintainers can confirm.

Screen Shot 2022-06-09 at 10 17 28 AM

To be honest, sidebar sticking to the edge of a large screen, while having the navbar centered does looks odd. So on docs pages, if the navbar has to be centered, the sidebars should be as well.

On non-docs pages, the centered navbar might be preferable for some. But on the docs pages, both the options (full-width navbar + left-aligned sidebar vs centered page) have their uses.

Might be a better idea to make this configurable, and part of a larger task?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navbar remain to the center with my own width in large screen
I have one navbar in one website that im building which is full width in large screen. I am trying to make it...
Read more >
A Full-Width Centered Navigation Bar - CSS Reset - CSSDeck
This horizontal navigation bar stretches the full width of the screen but centers the navigation over your content. It's easy, clean, and CSS-only....
Read more >
How To Create Equal Width Menu Links - W3Schools
Equal Width Navigation Links with Icons​​ Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.
Read more >
A Flexible Approach to Responsive Navigation
Many responsive websites provide a horizontal navigation bar on large screens and drop-down navigation for smaller viewports.
Read more >
Styling a responsive navigation bar - Web design tutorial
Webflow's navbar element is very flexible when it comes to styling. In this video, we're going to focus on five areas that give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found