I think it might have to do with the position attribute I set to sticky for the navbar and therefore the reason the media query is not resizing the sidebar?
https://codepen.io/Mark-Matlock/pen/gOyyxLb
styles.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Open Sans", Arial, sans-serif;
color: #4d4e53;
}
a {
text-decoration: none;
color: inherit;
}
.container {
display: flex;
}
#navbar {
position: sticky;
height: 100vh;
top: 0;
width: 350px;
}
header .logo {
width: 350px;
padding: 1rem 0 1rem 1.5rem;
border: 1px solid #4d4e53;
border-top: none;
}
header h2 {
color: #fff;
}
.nav__links {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}
.nav__links li {
padding-top: 1rem;
padding-bottom: 1rem;
padding-left: 1.5rem;
list-style: none;
border: 1px solid #4d4e53;
}
.nav__links li:last-child {
flex-grow: 1;
}
#main-doc {
flex: 1;
margin-left: 2.5rem;
margin-right: 2rem;
margin-bottom: 3rem;
}
#main-doc p {
margin-left: 1rem;
}
#main-doc ul {
margin-left: 4rem;
}
.main-heading {
font-size: 1.8rem;
padding-bottom: 1.5rem;
padding-top: 1rem;
color: #fff;
}
pre code {
background-color: #f7f7f7;
display: block;
margin-left: 1.5rem;
margin-top: 0.5rem;
padding-top: 1rem;
padding-bottom: 0.5rem;
padding-left: 0.5rem;
line-height: 1.5rem;
border-radius: 5px;
}
.nested-list li {
padding: 0.5rem;
}
a[class="mdn-link"] {
text-decoration: underline;
color: #3391ff;
}
@media (max-width: 480px) {
#navbar {
width: 200px;
}
}
index.html (some redacted to keep code brief)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles.css" />
<title>technical-documentation-page.freecodecamp.rocks</title>
</head>
<body>
<div class="container">
<nav id="navbar">
<header>
<div class="logo"><h2>JS Documentation</h2></div>
</header>
<ul class="nav__links">
<li><a class="nav-link" href="#Introduction">Introduction</a></li>
<li><a class="nav-link" href="#What_you_should_already_know">What you should already know</a></li>
<li><a class="nav-link" href="#JavaScript_and_Java">JavaScript and Java</a></li>
<li><a class="nav-link" href="#Hello_world">Hello world</a></li>
<li><a class="nav-link" href="#Variables">Variables</a></li>
<li><a class="nav-link" href="#Declaring_variables">Declaring variables</a></li>
<li><a class="nav-link" href="#Variable_scope">Variable scope</a></li>
<li><a class="nav-link" href="#Global_variables">Global variables</a></li>
<li><a class="nav-link" href="#Constants">Constants</a></li>
<li><a class="nav-link" href="#Data_types">Data types</a></li>
<li><a class="nav-link" href="#if...else_statement">if...else statement</a></li>
<li><a class="nav-link" href="#While_statement">while statement</a></li>
<li><a class="nav-link" href="#Function_declarations">Function declarations</a></li>
<li><a class="nav-link" href="#Reference">Reference</a></li>
</ul>
</nav>
<main id="main-doc">
<section class="main-section" id="Introduction">
<header class="main-heading">Introduction</header>
<article>
<p>JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.</p>
<br />
<p>JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects; for example:</p>
<br />
<ul>
<li>Client-side JavaScript extends the core language by supplying objects to control a browser and its Document Object Model (DOM). For example, client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation.</li>
<li>Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript on a server. For example, server-side extensions allow an application to communicate with a database, provide continuity of information from one invocation to another of the application, or perform file manipulations on a server.</li>
</ul>
</article>
Browser information:
Chrome Version 124.0.6367.91 (Official Build) (arm64)