Ways to relocate the menu within the confines of the "menu border"

Is it possible to move the menu inside the border on this webpage? I am new to web design and was thinking of using position:absolute for the links. Should I also move the submenu along with it? Any suggestions on how to achieve this? Thank you! The goal is to relocate the menu to the bottom right corner within the border.

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="videos.css" />
<link rel="stylesheet" type="text/css" href="vines.css" />
<title>Puppy Power</title>
</head>
<body>
        <div id="page">
<header></header>
        <div id="dog logo">
    </div>

<ul id="navigation">
        <li><a href="index.html">Home</a></li>
        <li><a href="videos.html">Videos</a>
            <ul class="sub">
                <li><a href="vines.html">Vines</a></li>
                <li><a href="#">Pugs</a></li>
                <li><a href="#">Failing Dogs</a></li>
                <li><a href="#">Crazy Dogs</a></li>
                <li><a href="#">Funny Dogs</a></li>

            </ul>
        </li>


        <li><a href="#">Photographs</a></li>    
        <li><a href="#">Articles</a></li>
        <li><a href="#">Contact</a></li>
    </ul>

<div id="hero"><h1><b>HERO</b></h1></div>


<div id="topvideo"><h1><b>TOP VIDEO</b></h1></div>

<div id="topphoto"><h1><b>TOP PHOTO</b></h1></div>

<div id="toparticles"><h1><b>TOP ARTICLE</b></h1></div>

<div id="content"><h1><b>CONTENT</b></h1></div>

<div id="footer"><h1><b>FOOTER</b></h1></div>

</body>
</html>

#page {
    max-width: 850px;
    min-width: 840px;
    min-height: 1550px;
    max-height: 1600px;
} 

* {
    margin: 0px;
    padding: 0px;
}



#navigation {
    border: 1px solid #89cFF0;
    width: 813px;
    height: 187px;
    margin-left: 5px;

}



ul #navigation, .sub {
    list-style-type: none;


}

ul #navigation li {
    border: 1px solid #89cFF0;
    width: 125px;
    text-align: center;
    position: relative;
    float: left;
    list-style-type: none;
}

ul #navigation a {
    text-decoration: none;
    display: block;
    width: 125px;
    height: 25px;
    line-height: 25px;
    border: 1px solid #89cFF0;
}

ul #navigation li:hover > a {
    background-color: #89cFF0;
}



#hero {
    width: 813px;
    height: 408px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    margin: 5px 0px 0px 0px;
    text-align: center;
    color: red;

}

#topvideo {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;



}

#topphoto {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;

}

#toparticles {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;
}

#content {
    width: 813px;
    height: 310px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    margin: 0px 0px 0px 0px;
    text-align: center;
}

#footer {

    width: 813px;
    height: 100px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    margin: 5px 0px 0px 0px;
    text-align: center;
}

Answer №1

The issue with the CSS code lies in your selectors where you are consistently placing #navigation in incorrect locations, causing it to disrupt your CSS. Specifically, the rule for your li element is as follows:

ul #navigation li {
    border: 1px solid #89cFF0;
    width: 125px;
    text-align: center;
    position: relative;
    float: left;
    list-style-type: none;
}

The corresponding HTML snippet looks like this:

<ul id="navigation">
        <li><a href="index.html">Home</a></li>
        <li><a href="videos.html">Videos</a>
            <ul class="sub">
                <li><a href="vines.html">Vines</a></li>
                <li><a href="#">Pugs</a></li>
                <li><a href="#">Failing Dogs</a></li>
                <li><a href="#">Crazy Dogs</a></li>
                <li><a href="#">Funny Dogs</a></li>

            </ul>
        </li>


        <li><a href="#">Photographs</a></li>    
        <li><a href="#">Articles</a></li>
        <li><a href="#">Contact</a></li>
    </ul>

Your current CSS is attempting to style a <li> that is a child of #navigation which itself should be a child of <ul>, but there is no intermediate <ul> as #navigation represents the ul directly. A better way to select it would be:

#navigation li {
    border: 1px solid #89cFF0;
    width: 125px;
    text-align: center;
    float: left;
    list-style-type: none;
}

JSFiddle Demo

Updated CSS:

#page {
    max-width: 850px;
    min-width: 840px;
    min-height: 1550px;
    max-height: 1600px;
} 

* {
    margin: 0px;
    padding: 0px;
}



#navigation {
    border: 1px solid #89cFF0;
    width: 813px;
    height: 187px;
    margin-left: 5px;

}



#navigation , .sub {
    list-style-type: none;


}

#navigation li {
    border: 1px solid #89cFF0;
    width: 125px;
    text-align: center;
    float: left;
    list-style-type: none;
}

#navigation   a {
    text-decoration: none;
    display: block;
    width: 125px;
    height: 25px;
    line-height: 25px;
    border: 1px solid #89cFF0;
}

#navigation   li:hover > a {
    background-color: #89cFF0;
}



#hero {
    width: 813px;
    height: 408px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    margin: 5px 0px 0px 0px;
    text-align: center;
    color: red;

}

#topvideo {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;



}

#topphoto {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;

}

#toparticles {
    width: 267px;
    height: 370px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    display: inline-block;
    vertical-align:top;
    text-align: center;
    margin: 5px 0px 5px 0px;
}

#content {
    width: 813px;
    height: 310px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    margin: 0px 0px 0px 0px;
    text-align: center;
}

#footer {

    width: 813px;
    height: 100px;
    border-top: 1px solid #89cff0;
    border-bottom: 1px solid #89cff0;
    border-left: 1px solid #89cff0;
    border-right: 1px solid #89cff0;
    margin: 5px 0px 0px 0px;
    text-align: center;
}

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

Create widget that is resistant to inherited traits

In our development process, we are crafting a widget designed to be seamlessly integrated into external websites. This integration involves the dynamic injection of a div element within the body of the page using Javascript. While the widget appears satis ...

Can the keydown event have an impact on setInterval functionality?

I created a basic snake game using JavaScript and attempted to incorporate a new feature where var trail = []; var tail = 5; var normal_speed = 1000 / 10 var speed = 1000 / 10; var game_status = 0; var my_game; button.addEventListener("click", function ...

Menu stack with content displayed to the right on larger screens

Given the content div's position (up middle), what method can I use to stack the divs in this manner? Is it possible to accomplish with only CSS or is jQuery necessary to move the div content out on larger screens? ...

Styling a div element in React

Just dipping my toes into the world of styling here, so bear with me. I'm currently working on a React app and attempting to bring an image from a file using the following code: import cup from './img/cup.png' My goal is to style it in co ...

Tips on applying a class to a host element using @hostbinding in Angular 2

I've been wanting to assign a class to the host element of my component, and initially I used the host property in this manner: @Component({ selector: 'left-bar', host: { 'class': 'left-bar' }, templateUrl: 'a ...

What steps can I take to prevent ng-bootstrap modal from automatically centering the content within the modal?

Looking for a solution to a UX issue with my Angular ng-bootstrap modal. The problem arises when displaying messages of varying lengths - if the message is longer than the screen's vertical resolution, it gets centered on the screen. This causes incon ...

Is it possible to make changes to local storage data without impacting the rest of the data set?

I am looking for a way to modify specific data in the local storage without affecting any other stored information. However, I have encountered an issue where editing values works correctly for the first three attempts, but on the fourth try, it seems to ...

Styling with CSS: Enhancing list items with separators

Is there a way to include a separator image in my list using CSS? li { list-style: none; background-image: url("SlicingImage/button_unselect.png"); height: 53px; width: 180px; } This is the code for the separator image: url("SlicingImage ...

"Bringing the power of JavaScript to your WordPress

I have set up a wordpress page and integrated some JavaScript into it. When working in wordpress, there are two tabs on a page where you can input text - 'Visual' and 'Text'. The 'Text' tab is used for adding HTML and scripts ...

CSS and HTML modal not closing

I've been working on creating a custom popup using HTML, CSS, and some jQuery functions. My idea was that when I click on the main div, it should expand in size and display a cancel button, which it does successfully. However, the issue arises when tr ...

Utilizing browser local storage in web development

Currently, I am in the midst of working on an e-commerce platform, a project that holds significant importance for me as it marks my debut into major projects. For the first time, I am delving into the realm of local storage to manage basket data such as q ...

"Encountered a 404 Error while attempting an Ajax

I am relatively new to web development and I am currently working on making a post method function properly. Below is the ajax call that I have implemented: $.ajax({ type: "POST", url: '/Controllers/AddPropertyData', ...

Do not display large numbers within an HTML card

I have this card here and displaying dynamic data inside it. The number is quite large, so I would like it to appear as 0.600000+. If a user hovers over the number, a tooltip should display the full number. How can I achieve this? Below is the HTML code ...

Creating fixed values in HTML

I need to maintain consistency in the headings of multiple tables spread across 3 HTML pages. The heading structure is as follows: <thead> <tr> <th>MyHeading</th> </tr> </thead> My goal is to store the string MyHeadin ...

Using Ajax to dynamically load page content into a div based on a selection made in a

How can I dynamically load content into a div using Ajax based on the selection made in a dropdown menu? For example, I have a select box with two options: test.HTML and test1.HTML. Below that, there is a div where I want to display the content from eithe ...

What is the best way to design a responsive menu that is perfectly centered?

I'm facing challenges with designing a menu that includes 4 items, needs to be centered next to each other with spacing in between, and should stack vertically on mobile devices. The desired look for the menu can be viewed in this image... Could some ...

Concealing the footer on a webpage embedded within an iframe

<script> $(document).ready(function(){ $('.mydivclass').hide(); }); </script> Looking to embed Microsoft Forms in my HTML using an iframe. Can the footer of the Microsoft Forms be removed? ...

Do you require a lightbox for a white text box set against a semi-transparent black background?

Currently, I am in the process of developing a Chrome extension that will be compatible with my Android app. As part of this development, I need to code the HTML/CSS for the extension. The main functionality of the extension allows users to add tags to a s ...

Node.js has no trouble loading HTML files, however, it seems to encounter issues when trying to

Having a bit of trouble with my JavaScript skills as I try to load my index.html file (seems like it should be the 5th easiest thing to do in JavaScript). Let me get straight to the point; when I manually open my index.html, it loads perfectly WITH the CS ...

Bootstrap arranges checkboxes into three evenly spaced columns and centers them within a form

Having trouble organizing my checkboxes into 3 columns and centering them within the form perfectly. Current layout: Click here for image Desired look: Click here for image HTML: ` <form action="/signup" method="POST" ...