Stop navigation links from resizing when the page content does not fill the height of the display

As I work on my very first website, I've encountered a strange issue with the navigational links at the top of each page. I've noticed that pages with content exceeding the maximum vertical pixels occupy a specific width, while those with less content have a different width, even though the menu code remains the same. Why does this occur and how can it be fixed? Below is the code snippet:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>About</title>
    <link rel="stylesheet" type="text/css" href="about_style.css" />
</head>
<body>
    <nav id="menu">
            <ul>
                <li id="home"><a href="../index.html">Home</a></li>
                <li id="news"><a href ="../news/index_news.html">News</a></li>
                <li id="tragic_complexity"><a href="../tragic/index_tr.html">Tragic Complexity</a></li>
                <li id="d_diary"><a href="../diary/d_diary.html">D Diary</a></li>
                <li id="geeks"><a href="../geeks/geeks.html">Geeks = 1</a></li>
                <li id="about">About</li>
            </ul>
        </nav>
    <ul id="info">
        <li>
            About the site
        </li>
        <li>
            About the founder
        </li>
    </ul>
</body>
</html>

css file:

body
{
    background-image:linear-gradient(#336666, #66cccc);

}
#info,#menu
{
    text-align:center;
}
#info li
{
        display:block;
        font-family:serif;
        height:300px;
        width:600px;
        border:1px solid black;
        overflow:hidden;
        padding: 10px 10px 10px 10px;
        border-radius: 10px 10px 10px 10px;
        margin:20px auto 20px auto;
        background-color:white;
}
#menu ul li
{
    display: inline-block;
    margin:auto 20px auto 20px;
    font-size: 150%;
    font-family: Arial, Verdana, sans-serif;

}

Answer №1

Perhaps the reason for this issue is simply because a vertical scrollbar appears on longer pages but not on shorter ones. To eliminate this discrepancy, you can enforce the presence of the scroll bar regardless of the content height.

Here are some resources that explain how to do so:

http://css-tricks.com/snippets/css/force-vertical-scrollbar/

As mentioned in the first link:

html {
     overflow: -moz-scrollbars-vertical;
     overflow: scroll;
}

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

What do you think about removing the Bootstrap styling from the design?

As a newcomer to Bootstrap and currently working on my second project using this framework, I find myself struggling with overriding CSS styles. It can be time-consuming to locate the specific style that needs to be changed rather than starting from scratc ...

Error encountered during submission due to integrity issues

I am currently working on an application that allows users to report a film to the admin database. The issue I am facing is that when I try to report a movie by clicking on the report button and filling out the report_form template, I encounter the followi ...

What is the best way to horizontally align two elements that are individually contained within <span> tags?

Is there a way to center a group of CSS buttons on a webpage? Currently, the buttons are aligning to the left even though I have set display: inline-block;. I have found that I can center them by adding an additional parent div and giving it an id with dis ...

The issue with hiding elements using .setAttribute in HTML/CSS is not occurring as expected

function showEditStudentProfile() { document.getElementById('editstudentprofile').setAttribute('class', 'unhide'); document.getElementById('profile_viewStudent').setAttribute('class', ' ...

Elevate a division within its container

Is there a way to make a smaller div positioned at the top when it's placed next to a larger one in the same container? I'm looking for a solution that doesn't involve using position-relative and manually adjusting the placement. Take a loo ...

What is the best way to navigate to the top of a form panel?

I'm currently developing a Sencha Touch mobile app. I have a form panel with multiple fields, so I made it scrollable. However, every time I open the screen (panel), scroll down, navigate to other screens, and then return to the form panel, it stays s ...

Error encountered when attempting to retrieve DateTime from MySQL in PHP: Undefined Index

I'm in the process of setting up a webpage that will display event information fetched from a MySQL Database. I am using a PHP function to retrieve this data and include the datetime of the events. Currently, my PHP function is successfully populatin ...

Trigger a click event on a div element that is nested within a form

Having trouble displaying an alert when clicking on a disabled button because the user needs to first click on a terms checkbox. Here's my jQuery code: $('#divButton').on("click", function() { if ($('#buybutton').prop('d ...

Unable to find a bootstrap dropdown component using Python in Selenium

I am currently facing an issue trying to find a dropdown menu and select an option. Below is the code snippet I have been using for this task: from selenium import webdriver driver=webdriver.Chrome(r"C:\Users\nithi\Downloads\chrom ...

Is there a way to make all DIVs in the same class have the same height as the tallest div?

I have 3 identical divs with an auto height value. How can I set the height of all divs in the same class to be equal to the highest div's height? Same Class Div Thank you in advance. ...

Place the Div directly above a distinct Div

Hey there! I'm currently working on positioning one div on top of another div programmatically (using javascript or css). These divs are completely separate and have the following structure: <div class="bottom"> <img src="image"></i ...

I am experiencing difficulty closing my Bootstrap 5 nav bar once it has been clicked in mobile view

Having an issue with my Bootstrap 5 navbar in mobile view - it can be clicked to open, but won't close when clicked again. Currently using Bootstrap v5.0. If anyone has insight into why this might be happening, please let me know! <link href ...

Allowing horizontal scrolling in a table cell set to full width

I'm attempting to achieve the desired outcome by utilizing the code provided at What I'd like to know is why the scrolling function isn't working as expected. Instead of scrolling, it simply expands the table. To see the difference, try run ...

Linked dropdowns with an HTML table feeding data

I have a piece of code that is currently being used to filter user selections. However, I am interested in utilizing an existing HTML table as the data source for the igcombo box instead of the JavaScript array. How can I achieve this? Below is the code s ...

Should the HTML inputs be positioned within the label or placed outside of it?

Check out this site for some on/off switches: <div class="onoffswitch"> <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked> <label class="onoffswitch-label" for="myonoffswitch"> < ...

Transition/transform/translate3d in CSS3 may lead to significant flickering on the initial or final "frame" of the transition (specifically on an iPad)

Hello everyone, I am currently developing a web application specifically for the iPad and I have implemented a CSS3 transition to animate a div, moving it from left to right. Here is the structure of my class: .mover { -webkit-transition:all 0.4s ea ...

Ways to merge multiple cells horizontally in a table right from the beginning

Is there a way to start the colspan from the second column (Name)? See image below for reference: https://i.stack.imgur.com/RvX92.png <table width="100%"> <thead style="background-color: lightgray;"> <tr> <td style="width ...

Pedestrian crossing Cordova experiences delayed response despite ontouchstart attempts to fix it

I have been experiencing a delay issue when using a CSS button with the ":active" pseudo-class on my phone. Every time I click the buttons, there is a noticeable delay before entering the active phase. Here is my CSS code: .btn {...} .btn:active{...} To ...

Swapping two values of input forms in HTML using jQuery interchangeably

I need help figuring out how to dynamically update the values of two input fields on a form interchangeably. For example, if input one represents the current price of Bitcoins and input two represents USD, I want to be able to change the value of one input ...

Troubleshooting Problem with React Slider: Inability to Display Images and Previous Button

I'm currently grappling with a React issue after following a tutorial on YouTube. I've been working in CodeSandbox and have encountered a problem where the images and previous button are not displaying as expected. Despite my efforts to debug, th ...