What is the best way to change the height of this menu bar?

I have a stylish menu that suits my website perfectly. However, when I add this menu to my page, I am struggling to make it fill the vertical length of the page (it is already vertical but not very long).

The only solution I have found is to adjust the length of the menu buttons, which makes the overall length longer but compromises the appearance of the buttons due to their height.

Here is my CSS:

    .menu_simple ul {
    margin: 0; 
    padding: 0;
    width:100px;
    list-style-type: none;
}

.menu_simple ul li a {
    text-decoration: none;
    color: white; 
    padding: 10.5px 11px;
    background-color: #BDBDBD;
    display:block;
}

.menu_simple ul li a:visited {
    color: white;
}

.menu_simple ul li a:hover, .menu_simple ul li .current {
    color: white;
    background-color: #5FD367;
}

And here is my HTML:

   <div class="menu_simple">
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
</div>

Essentially, I want the menu to expand vertically with just the background color if there are no additional menu buttons added.

I hope this explanation clarifies my issue. Thank you for your assistance.

Answer №1

Is this the solution?

FIDDLE

To make it work, you must adjust the height of the parent div to 100%, along with the html and body elements to establish a reference point for sizing the div. The grey background should be applied to the div itself rather than the menu items for a uniform stretched menu appearance. By setting display:inline-block on the div, you ensure its width matches that of the longest menu item instead of defaulting to 100% as a block-level element.

CSS

html, body {
    height:100%;
    width:100%;
    margin:0;
    padding:0;
}
div.menu_simple {
    height:100%;
    background-color: #BDBDBD;
    display:inline-block;
}
.menu_simple ul {
    margin: 0;
    padding: 0;
    width:100px;
    list-style-type: none;
}
.menu_simple ul li a {
    text-decoration: none;
    color: white;
    padding: 10.5px 11px;
    display:block;
}
.menu_simple ul li a:visited {
    color: white;
}
.menu_simple ul li a:hover, .menu_simple ul li .current {
    color: white;
    background-color: #5FD367;
}

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

Deactivate additional fields when choosing an option from the drop-down selection menu

When designing a form with a select dropdown that displays various options, I encountered an issue. I want to disable certain fields if a specific option is chosen from the dropdown. For instance, if "Within Company" is selected in the transaction type, I ...

jQuery Slider Showing Incorrect Images

My jQuery slider is acting strangely. It hides the first image, shows the second one, but then just repeats the cycle by showing the first image again instead of loading the third one. I'm puzzled about what could be causing this issue in my code. Do ...

The map obtained from the Google Maps API is covering up the footer on my website

I'm running into an issue with the Google Maps API on my website. When I try to resize the window, the map ends up covering the footer. My goal is to create some space between the map and the footer. Here's how it looks in a large window: And h ...

The Google Maps V3 API map is not loading completely

I'm currently in the process of developing an application that will display maps showcasing local dining establishments. Although the map does appear, it's taking an excessively long time to load and never fully loads as expected. My deadline i ...

Has anyone come across an XSLT that can effectively convert Apple Pages files into high-quality HTML?

When Apple’s word processor/DTP app Pages saves its files, it does so as zipped folders with an XML file containing the content and attachments like images stored as separate files. I am interested in converting this content into HTML format, using < ...

Is there a way to eliminate the black dots appearing on the right side of the navigation items within my bootstrap 5 navbar?

I'm currently using a bootstrap 5 navbar and everything seems to be functioning correctly, except for one issue - all the nav-items have a black dot on the right side of the text. Below is the code snippet for that particular section. I've made ...

jQuery wrapAll issue

I have a repeating group of three divs in my code that I need to wrap together. Here's an example from my HTML: <div class="one" /> <div class="two" /> <div class="three" /> <div class="one" /> <div class="two" /> <d ...

Prevent click event listener from activating if the click results in a new tab or window being opened

Occasionally, when using my web app, I need to prevent click event listeners from activating if the click is meant to open a new window or tab. For instance, in my single page application, there are links to other content. While they function well, there i ...

What could be causing the failure of this web component using shadow DOM when the HTML code includes multiple instances of the component?

Recently, a question was raised on this platform regarding the use of Selenium to access the shadow DOM. Curious about this topic, I delved into the MDN article Using shadow DOM and decided to replicate the code on my local machine. Surprisingly, it worked ...

Steps to Import an Image from a Subdirectory:

Currently, I am working on C# and HTML. While working on a view page, I encountered an issue when trying to load images from subfolders. When attempting to load an image from the immediate folder, it opens correctly. For example: <img data-u="image" s ...

Tips for adding a progress bar to your sidebar

I have a query regarding how to expand the width of a div within an li element. Essentially, as a user scrolls, the sidebar on the right-hand side will cause the span element (highlighted with a red background color) inside the li to transition from 0 to ...

Is it possible to make an element float or stay fixed on a web page based on the visible section of the page?

This question may be a bit confusing, but I couldn't phrase it any other way. Check out this link: Configure - Apple Store (U.S.) On the webpage, the 'Summary' box is positioned below the sub-header and aligns with the content block. When ...

Creating a dynamic 2x2 grid with centered responsiveness in Angular Ionic framework

I'm having trouble achieving a 2 x 2 grid that is centered on my screen. The code snippet below shows what I have so far in the HTML file. Just to provide some context, this project is meant for a native mobile application. <ion-header> <i ...

Preview and enlarge images similar to the way Firefox allows you to do

When you view an image in Firefox, it is displayed with the following characteristics: Centered within the browser window. Has a height/width that fits within the browser dimensions. Does not resize larger than its maximum size. Remains the same size if ...

Extracting Data: Unlocking Information from Websites

My friend and I are working on a school project that involves creating a small application. The main goal of this app is to find pharmacies in our area. I am looking to extract information from two specific websites. gun = day/date lc = id of town ...

"Enhance Your Website with Slider Swipe Effects using CSS3 and

After scouring the internet for various types of sliders, including swipe sliders, I am interested in creating a responsive swipe slider specifically for mobile phones. This would be a full page swipe slider where users can swipe left and right seamlessly. ...

My PHP code keeps prompting me with an "invalid password" message even though I am confident that the password is correct

As part of a project at work, I am creating an intentionally flawed application to showcase common security vulnerabilities. This application is designed to demonstrate improper practices and may even entice those looking to exploit it. We have robust logg ...

What are the common reasons for ajax requests to fail?

Every time I try to run the code with the provided URL, the alert() function in the error: function is triggered. Can someone please assist me with this issue? $("#button").click(function(){ $("#form1").validationEngine(); if($('div input[typ ...

My goal is to create a backend platform similar to Kinvey, utilizing Node.js, Sails.js, and MongoDB

Hey there! I'm looking to develop a backend service similar to Kinvey (but for HTML and HTML5) using node.js, sails.js, and mongodb. With this service, I want the capability to create, post, update, and delete data just like you can with Kinvey. Here& ...

The symbol for expanding and collapsing sections in the Bootstrap accordion is not dynamically updating

I'm facing an issue with my bootstrap accordions. I have two accordions and each one has an inner accordion. The first one is set to be opened by default. However, when I click on the second accordion, the icon of the first one does not update to a pl ...