Technical Documentation Page - Build a Technical Documentation Page

If you pop out the preview into a separate window and then widen that window enough you will see that the nav list is on the left side by itself and the content does not overlap it. Your issue is that when you narrow the window the content starts to overlap the nav. What is pushing the content over to the right? You are using a left margin to do that, which is perfectly fine. But the unit you are using for the value might not be the best choice. You are using 20%. This means that the left margin on the content will always be 20% of its parent, which is the body element. The body element automatically stretches out the entire width of the page, so that means the 20% on the left margin will be 20% of the entire width of the page. Can you see that as you narrow the window, 20% of the page will gradually be a smaller and smaller number and thus the amount of left margin will also become smaller? That’s why you content is overlapping the nav menu.

So you need to choose some other type of unit that isn’t dependent on the width of the browser window. That way the left margin will always be big enough to prevent the content from overlapping the menu.

1 Like

alright Thank you that worked, I added a margin left to the main-doc and now it won’t overlap it. Now I just have to design it, the problem is they are in the middle of the nav and they have a big dot before them, I want them sticking to the left but when I add a margin padding and give it a value of 0 is stays in the middle, as for borders I think I’m gonna have to custom change every single one so they all line up(hope that makes sence).

My code so far

<!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">
  </head>
  <body>
    <nav id="navbar">
      <header class="nav-head">JS Documentation</header>
      <ul>
        <li><a id="one" class="nav-link" href="#Introduction">Introduction</a></li>
        <li><a class="nav-link" href="#Hello_World">Hello World</a></li>
        <li><a class="nav-link" href="#Function_declarations">Function declarations</a></li>
        <li><a class="nav-link" href="#Variables">Variables</a></li>
        <li><a class="nav-link" href="#Constants">Constants</a></li>
     </ul>
    </nav>
   <main id="main-doc">
     
    <section class="main-section" id="Introduction">
      <header><h1>Introduction</h1></header>
      <code></code>
      <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>
      <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>
      <ul class="list">
        <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>continuity of information from one invocation to another of the application, or perform file manipulations on a server.</li>
      </ul>
    </section>
    <section class="main-section" id="Hello_World">
      <header><h1>Hello World<h1></header>
      <p>To get started with writing JavaScript, open the Scratchpad and write your first "Hello world" JavaScript code:</p>
      <p class="example"><code>function greetMe(yourName) { alert("Hello " + yourName); }
greetMe("World");</code></p>
      <p>Select the code in the pad and hit Ctrl+R to watch it unfold in your browser!
</p>
    </section>
    <section class="main-section" id="Function_declarations">
      <header><h1>Function declarations</h1></header>
      <p>A function definition (also called a function declaration, or function statement) consists of the function keyword, followed by:</p>
      <ul class="list">
        <li>The name of the function.</li>
        <li>A list of arguments to the function, enclosed in parentheses and separated by commas.</li>
        <li>The JavaScript statements that define the function, enclosed in curly brackets, { }.</li>
      </ul>
      <p>For example, the following code defines a simple function named square:</p>
      <p class="example"><code>function square(number) { return number * number; }</code></p>
      <p>The function square takes one argument, called number. The function consists of one statement that says to return the argument of the function (that is, number) multiplied by itself. The return statement specifies the value returned by the function.</p>
      <p class="example"><code>return number * number;</p>
      <p>Primitive parameters (such as a number) are passed to functions by value; the value is passed to the function, but if the function changes the value of the parameter, this change is not reflected globally or in the calling function.</code></p>

    </section>
    <section class="main-section" id="Variables">
      <header><h1>Variables</h1></header>
      <p>You use variables as symbolic names for values in your application. The names of variables, called identifiers, conform to certain rules.</p>
      <p class="example"><code>A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).</code></p>
      <p>You can use ISO 8859-1 or Unicode letters such as å and ü in identifiers. You can also use the Unicode escape sequences as characters in identifiers. Some examples of legal names are Number_hits, temp99, and _name.</p>
    </section>
    <section class="main-section" id="Constants">
      <header><h1>Constants</h1></header>
      <p>You can create a read-only, named constant with the const keyword. The syntax of a constant identifier is the same as for a variable identifier: it must start with a letter, underscore or dollar sign and can contain alphabetic, numeric, or underscore characters.</p>
      <p class="example"><code>const PI = 3.14;</code></p>
      <p>A constant cannot change value through assignment or be re-declared while the script is running. It has to be initialized to a value.</p>
      <p>The scope rules for constants are the same as those for let block scope variables. If the const keyword is omitted, the identifier is assumed to represent a variable.</p>
      <p>You cannot declare a constant with the same name as a function or variable in the same scope. For example:</p>
      <p class="example"><code>// THIS WILL CAUSE AN ERROR function f() {}; const f = 5; // THIS
WILL CAUSE AN ERROR ALSO function f() { const g = 5; var g;
//statements }</code></p>
      <p>However, object attributes are not protected, so the following statement is executed without problems.</p>
      <p class="example"><code>const MY_OBJECT = {"key": "value"}; MY_OBJECT.key =
"otherValue";</code></p>
    </section>
  </main>
  </body>
</html>

CSS
*:not(h1){
  font-size:19px;
}

.example{
  background-color:#d3d3d3;
  padding:20px;
  margin-left:20px;
}
.list{
  padding: 8px 75px;
}
#navbar{
  position:fixed;
  float:left;
  width:250px;
  height:100%;
  margin-left:0px;
}
.nav-head{
  font-size:20px;
  font-style:bold;
}
.nav-link{
  text-decoration:none;
  color:black;
  border:1px solid black;
  padding-left:0;
}
#main-doc{
  margin-left:150px;
}
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.