The navbar shifts position when inserting HTML code

I am encountering some difficulties with my online portfolio. The page layout includes a navigation bar on the right side and an image as the background in the same div. I am trying to add introductory text to my portfolio, but whenever I do so, the nav bar moves down. Is there a solution to this issue?

Below is the code I've been using:

@import url('https://fonts.googleapis.com/css?family=Fjalla+One');
@import url('https://fonts.googleapis.com/css?family=Titillium+Web');
*{
    margin: 0 auto;
    padding: 0;
}
#wrapper {
    margin: 0 auto; 
}

#background {
    display: block;
    background-image: url(images/profile/Untitled-1.jpg);
    background-repeat:no-repeat;
    background-size:contain;
    -webkit-filter: grayscale(80%); /* Safari 6.0 - 9.0 */
    filter: grayscale(80%);
    margin: 0 auto;
    border: 1px solid black;
}

header {
    margin-left: 10px;
    
    padding-left: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
}
p {
    display: block;
    width: 20%;
    font-size: 40px;
    color: antiquewhite;
    padding: 0;
    margin: 0 auto;
}

body {
    background-color: black;
}

footer{
    color: antiquewhite;
}

h1 {
    font-family:'Fjalla One', sans-serif;
    color: floralwhite;
    font-size: 300%;  
}
ha {
    display: block;
    width: 50%;
    font-family:'Titillium Web', sans-serif;
    color: floralwhite;
    font-size: 100%;
}

nav {
    display: block;
    margin-left: 80%;
    border: 2px solid orange;
    margin-bottom: 40%;
}
li{
    display: inline-block;
    padding: 20px;
    margin: 9px 0px;
    border-radius: 50px 0px 0px 50px;
    border: 2px solid white;
    width: 250px;
    height: 50px;
    text-align: center;
    text-shadow: 2px 2px black;
    font-size: 150%;
    font-family: 'Fjalla One', sans-serif;
    background-color: dimgray;
    position: relative;
    -webkit-transition-duration: 0.5s;
    transition-duration: 0.5s;
    -webkit-transition-property: transform;
    transition-property: transform;
}

.stretch:hover {
    -webkit-transform: translateX(-25px);

}

@keyframes extend{
    from {width: 200px; left:0px;}
    to   {width: 600px; left: 200px;}
}

li:hover{
    -webkit-animation-name: "extend"; 
    -webkit-animation-duration: 2s;
     animation-direction: reverse;
}
    
a:link {
    text-decoration: none;
    color: antiquewhite;
}

a:visited {
    text-decoration: none;
    color: antiquewhite;
}

a:hover {
    text-decoration: none;
    color: antiquewhite;
}

a:active {
    text-decoration: none;
    color: antiquewhite;
}
 <!DOCTYPE html>
 <html lang="en">
    <head>
       <link rel="stylesheet" media="screen" href="home.css">
       <title>Tavyon Richardson</title>
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0" >
       <script src="jquery-3.1.1.min.js">
       </script>
    </head>
    <body>
       <div id="wrapper">
          <header>
             <h1>Tavyon Richardson</h1>
          </header>
          <p><span>Hey!</span>Welcome to my webiste. Here, you can see everything from my life story, to my latest projects and resume.</p>
          <div id="background">
             <nav id="navbar">
                <ul>
                   <li class="stretch"><a href="">About me</a></li>
                   <li class="stretch"><a href="">Courses</a></li>
                   <li class="stretch"><a href="http://tavyonrichardson.com/projects.html">Projects</a></li>
                   <li class="stretch"><a href="http://tavyonrichardson.com/nms_114/blog">Blog</a></li>
                   <li class="stretch"><a href="">Resume</a></li>
                </ul>
             </nav>
             <footer>last updated November 2016</footer>
          </div>
        
       </div>
    </body>
</html>

Answer №1

To display the text below the navigation bar, it should be included in the actual HTML structure or you can apply CSS properties like position: fixed;. Alternatively, you may utilize top: and left: properties for positioning.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

PHP and HTML form: The ultimate guide to sending emails through your website

Currently, I am in the process of learning PHP and attempting to send an email to myself using an HTML form. However, I am experiencing some difficulties. <form action="index.php" role="form" method="post" name="emailform"> ...

I'm having an issue with my radio button list where it is allowing multiple selections at once. Can anyone explain

My web application features two radio button lists that allow users to select multiple items. These lists are dynamically generated using data from an API accessed via AJAX. Below, you can see images depicting the functionality: Here is a snippet of the ...

What steps can I take to prevent the array from constantly updating and instead only show the final task?

<h1>Custom Calendar and Task Scheduler</h1> <div class="navigation-text">Use the arrows to switch between months</div> <div class="navigation-text">Click on a date to create tasks</div> &l ...

Tips for condensing text using ellipsis and Angular-FlexLayout

I am working on a flex row setup that includes three nested flex rows. Within the second row, I need to display a title that should not be shortened, and a text that should be truncated. Additionally, the first and last row must maintain a fixed width with ...

Styling a webpage with a two-row layout using just CSS

I am looking to design a 2-row layout for a webpage where one row will contain filters and the other row will display results. The layout should meet the following criteria: The page height should not exceed 100% The first row's height will vary bas ...

Elevate a div over another div

I have a situation where I need to nest two divs inside another div with the ID "video-wrapper". Here is the HTML code: <div class="row"> <div class="video-wrapper col-lg-2"> <div class="video-thumbnail"> <img ...

The process of setting up React in the terminal becomes tricky when the VS code editor is directing to a non-existent path

Issue with VS Code editor not recognizing existing path Recently attempted to install React using the npx command in the terminal, following steps from various tutorials on YouTube. Despite trying all suggested methods, the installation didn't succee ...

Using the pattern `[A-Za-z]{50}` in HTML is mistakenly identifying valid input as invalid

I created a webpage with text fields and wanted to limit user input using the HTML5 pattern attribute. Here is an example of how I implemented it: <input name="team_name" type="text" pattern="[A-Za-z]{50}" value="<?php echo $team_name;?>"> Ev ...

Attempting to ensure that my website is fully optimized for all devices and

I am currently facing an issue with my CSS code on iPad. I want to change the background-image displayed based on whether the user is using an iPad or not. Specifically, I want to use headerold.jpg as the background-image for iPads while keeping headernew. ...

Unusual behavior observed in Google Font when using display=swap

After attempting to integrate a Google Font API into my website by adding the following code to my HTML: <link href="https://fonts.googleapis.com/css?family=Playfair+Display|Source+Serif+Pro|Suwannaphum&display=swap" rel="stylesheet"> I encount ...

Sending multiple unique forms with the same structure using JavaScript and Ajax on a single PHP page

In my PHP page, there are 12 individual forms with unique form IDs, checkboxes, and dropdowns. Take a look at this image: https://i.stack.imgur.com/pODzk.png Each form has an Update Zone that fetches Name, Enable status, Time, Dim information, and sends ...

The CSS dropdown menu appears in a horizontal layout rather than vertical

** body { background-color: #9cb4c0; background-size: 100% 100%; } .div-1 { float: right; padding: 20px 10px; } h2 { text-align: right; ...

Having trouble with my HTML and PHP form submission. Can anyone help me figure out what's going on?

Hello, I'm in the process of creating a contact form for a website I'm currently working on, but I'm encountering some difficulties with properly configuring the syntax to send the form data to an email address. At the moment, I'm faci ...

Guide to placing a basic div directly over a basic html table td

I need to create a simple html table with labels in one column and content in another. What I want to achieve is placing a div over the content td while keeping the label visible. I am looking for the most efficient way to do this, possibly making the seco ...

Select an option from the navigation bar - the chosen item will remain highlighted

My Navbar code looks like this: <Navbar.Collapse> <Nav> <NavItem eventKey={1} href={`${process.env.PUBLIC_URL}/`}> Blah </NavItem> <NavItem eventKey={1} href={`${process.env.PUBLIC_URL}/SomePage`} ...

Question about the origin of style sheet source files [*.css?ver=]

Can you explain the purpose of appending a query string to the end of a style sheet? I frequently come across examples like this: some-stylesheet.css?ver=1.2.3 Appreciate your insights. ...

I prefer to have the div element on its own line without using <br>, as I find it neater that way

I am currently working on a website layout that includes a header with a menu option on the left, a title in the center, and a link to the logIn/signUp page. You can view an image of this layout here: https://ibb.co/z6R1h6w Unfortunately, the login and sig ...

Conceal redundant items within an array without permanently deleting them

Is it feasible to achieve this task? Consider the following example: [4, 5, 6, 6, 6, 6] It is required to hide certain values such as: [4, 5, ***6, 6, 6*** 6] To hide elements with ***, use: .style.visibility = "hidden" ...

Issues have been reported with Safari mobile on iOS version 10.2.1 where CSS links are not being detected

I am in the process of creating a website using HTML, PHP, JavaScript, and CSS. All three languages are included in the same document with a link to an external CSS file. As I test for browser compatibility, I discovered that Safari on iOS 10.2.1 is unable ...

Render data from a RESTful Express API using AJAX and Node.js to display on a webpage

New to node.js development and facing a specific issue. My goal is to build a single-page web app using node.js where users can submit request data, retrieve information from the IMDb API, and display it on the same page. Here's my code: server.js # ...