If you find something useful on here, it's probably an accident.

New navigation custom CSS for Stack Exchange

After much time in beta and quite a bit of testing, the new top nav is out, with many concerns unaddressed. I'm generally welcoming of change, such as the move to the new design across SE, but this top bar isn't ideal. I've written some CSS to try to make it look a little nicer. Some things have been rearranged to be closer to the original design — not just to make it closer to the original but because I preferred the original layout. Here's what it looks like:

CSS applied to the new nav bar on Stack Overflow

Here are the main problems I had with the existing bar:

  • The height whilst being sticky. I have no problems with the height of the bar when it's static on a page, but being sticky means it simply takes up too much room on the page. I do like the nav being sticky, and even made the previous top bar sticky with a stylesheet, but with this sticky bar it simply takes up too much room.
  • The actions are on the right hand side. This isn't in the normal viewing direction, which is just plain odd once you're logged in. Logged out, fair enough, but logged in, these are the most important buttons. I use the inbox and achievements dropdown modals constantly, which mean they need to be in the top-left.
  • A ridiculous animation on search. Seriously, what is this? You click in the box, but unlike a normal search box animation which moves the end of the box, oh no, they move the start of the box. This completely repositions the insertion point at least the entire search box width away from where it started. Absolutely ridiculous. Clearly no-one uses the on-site search, mainly because Google exists, but it's still a useful feature which I do use especially for combining searches with tags, users or other advanced search features.

Things I've changed:

  • It's a lot thinner. This means it can remain sticky without encroaching much on the content within.
  • Actions are moved before the navigation. This means the inbox and such is on the left instead of the right, since I use these buttons more often. This was done with flex order, so no JavaScript required for actually manipulating the DOM.
  • Individual actions themselves have been rearranged. The Stack Exchange button is now left-most. Again, this uses flex order.
  • Search is no longer animated. Much less distracting, unlike having the insertion point move miles away from where it started.
  • Each dropdown occupies the same position, rather than starting from a location relative to the button.
    New navigation custom CSS for Stack Exchange
  • The navigation fades very slightly on scroll. Only slightly. Feel free to disable this if you're not a fan, but I feel it makes the text blend better with the rest of the page when you're much less likely to use it.
  • The logo and search box are slightly smaller to fit with the narrower bar. None of the other components had their text size or svg scale change.
  • The new nav and dropdown boxes have a -webkit-backdrop-filter applied. If your browser is not compatible with this, you should remove it. Alpha without a blur looks awful.
  • The box shadow is applied constantly, not only on scroll. Having the shadow flicker on and off was pretty distracting for me, I'd rather it just be constant. It's not much of a shadow anyway.
  • The header is sticky using sticky and -webkit-sticky. This works better for me than using fixed.

You’ll need Stylish (or equivalent) for your browser to be able to import this custom stylesheet.

Here's the full stylesheet:

.so-header {
	height: 34px !important;
	position: sticky !important;
	position: -webkit-sticky !important;
	border-top: none !important;
	box-shadow: 0 1px 0 rgba(12, 13, 14, 0.1), 0 1px 3px rgba(12, 13, 14, 0.1), 0 4px 20px rgba(12, 13, 14, 0.035), 0 1px 1px rgba(12, 13, 14, 0.025) !important;
	-webkit-backdrop-filter: blur(20px);
	background: rgba(255, 255, 255, 0.8) !important;
}
.so-header .-main {
	order: 2;
}
.so-header .-logo {
	height: 40px !important;
	transform: scale(.85);
	margin-left: -25px !important;
}
.so-header .navigation {
	max-width: unset !important;
	opacity: 1 !important;
}
.so-header .navigation .beta-badge {
	top: 22px !important;
}
.so-header._scrolling .navigation {
	opacity: .8 !important;
}
.so-header .navigation .-link, .so-header .secondary-nav .-link {
	height: 35.5px !important;
	margin-top: 10px !important;
	padding-top: 0 !important;
	line-height: 36px !important;
}
.so-header .searchbar {
	margin-left: 20px;
	margin-right: 10px;
}
.so-header .searchbar>[role="icon"] {
	transform: scale(.7) translateY(-70%) !important;
	margin-left: -8px !important;
	opacity: 1 !important;
}
.so-header .searchbar input[type="text"].f-input {
	height: 26px !important;
	padding-left: 25px !important;
	padding-top: 9px !important;
}
.so-header .searchbar .btn {
	transform: scale(.6) translateY(-82%) translateX(11px) !important;
}
.so-header .-actions {
	order: 1;
	height: 36px !important;
	margin-left: -8px !important;
	margin-right: 48px !important;
}
.so-header .my-profile {
	order: 1;
	height: 34px !important;
}
.so-header .my-profile .gravatar-wrapper-24 .-avatar {
	height: 18px;
	width: 18px;
}
.so-header .secondary-nav .-list .-item:not(:last-of-type) {
	order: 1;
}
.so-header .secondary-nav .-list .-item:last-of-type {
	order: 0;
}
.so-header~.container {
	padding-top: 0px !important;
}
.topbar-dialog, #sox-settings-dialog.topbar-dialog.achievements-dialog.dno.new-topbar {
	left: 6px !important;
	top: 34px !important;
	background: rgba(255, 255, 255, 0.8) !important;
	-webkit-backdrop-filter: blur(20px);
}

If you use SOX, append the following to keep the action buttons in the correct order.

.so-header .secondary-nav .-list .-item:first-of-type {
	order: 2;
}
Need help?