The styled horizontal list item has a background color that is not covering the entire

After setting up my CSS, I noticed a discrepancy in how the background color behaves when hovering over links in the navigation versus links in the footer. While the entire "button" area is filled with the background color in the nav, only the space behind the text is filled in the footer. I'm looking for a solution to ensure that the entire "button" is filled in the footer without relying on classes or images (utilizing HTML5/CSS3 as much as possible). Any ideas on how to resolve this issue?

I have tested this in multiple web browsers and suspect it might be due to the list items being displayed inline, but I haven't been able to find a solution yet.

--- Updated CSS ---

@CHARSET "UTF-8";

* {
margin: 0;
padding: 0;
}

html * {
    margin: 0;
    /*padding: 0; SELECT NOT DISPLAYED CORRECTLY IN FIREFOX */
}

/* GENERAL */

body {
    background: #fff;
    color: #333;
    font-family: verdana, "MS Trebuchet", arial, helvetica, sans-serif;
    font-size: 62.5%;
    margin: 0 auto;
    width: 960px;
}

header {
    background-color: #999;
    border: 1px solid #999;
    border-radius: 25px;
    margin-top: .5em;
}

header h1 {
    color: #fff;
    font-weight: bold;
    font-size: 2.4em;
    margin: .8em 0 .3em 0;
    text-align: center;
}

nav {
    margin: 1em 30em;
    padding: .8em 1.2em;
}

nav ul {
    padding-left: 1.5em;
    list-style: none;
}
nav ul li {
}
nav ul a {
    display: block;
    text-decoration: none;
}
nav ul li a {
    background-color: #FFF;
    border: 1px solid #999;
    border-radius: 25px;
    color: #222;
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 5px;
    margin-bottom: 5px;
    padding: 12px 10px;
    text-align: center;
    text-decoration: none;
}
nav ul a:hover {
    color: #333;
    background: #ccc;
}

nav#baseball {
    display: none;
}
nav#football {
    display: none;
}

footer {
    border-top: 1px solid #ccc;
    margin-top: .5em;
    margin-bottom: 1em;
    padding: .8em 1.2em;
}

footer ul {
    list-style: none;
    text-align: center;
}

footer ul li { 
    border: 1px solid #999;
    border-radius: 25px;
    display: inline; 
    margin: 0.0em 1.0em 0.0em 1.0em;
    padding: 0em 1.5em 0 1.5em;
}
footer ul a {
/*    display: block; */
    text-decoration: none;
}
footer ul li a {
    color: #222;
}
footer ul a:hover {
    color: #333;
    background: #ccc;
}

--- Updated HTML ---

<header>
    <h1>Sports Fan</h1>
</header>

<nav id='sports'>
    <ul>
        <li><a href="about-temp.html">Baseball</a>
        </li>
        <li><a href="blog-temp.html">Basketball</a>
        </li>
        <li><a href="consulting-clinic-temp.html">Football</a>
        </li>
        <li><a href="contact.html">Hockey</a>
        </li>
        <li><a href="contact.html">Soccer</a>
        </li>
    </ul>
</nav>

<nav id='baseball'>
    <ul>
        <li><a href="homerun.html">Homerun</a>
        </li>
        <li><a href="bighit.html">Big Hit</a>
        </li>
        <li><a href="doubleplay.html">Double Play</a>
        </li>
        <li><a href="doubleplay.html">Bad Call</a>
        </li>
    </ul>
</nav>

<nav id='football'>
    <ul>
        <li><a href="about-temp.html">Touchdown</a>
        </li>
        <li><a href="blog-temp.html">Big Play</a>
        </li>
        <li><a href="consulting-clinic-temp.html">Sack</a>
        </li>
        <li><a href="contact.html">Interception</a>
        </li>
        <li><a href="contact.html">Bad Call</a>
        </li>
    </ul>
</nav>

<footer>
    <ul>
        <li><a href="choose.html">Choose</a>
        </li>
        <li><a href="manage.html">Manage</a>
        </li>
        <li><a href="about.html">About</a>
        </li>
    </ul>
</footer>

Answer №1

Updated the code and placed it in a jsFiddle

Here are the CSS changes made:

footer li{ display:inline }

footer ul a{ 
    border: 1px solid #999;
    border-radius: 25px;
    display: inline-block; 
    margin: 0.0em 1.0em 0.0em 1.0em;
    padding: 0em 1.5em 0 1.5em;
    text-decoration: none;
    color: #222;
}

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

Unable to display image on HTML page transmitted via socket in Java

After successfully loading my simple HTML in Chrome and seeing it display correctly, I encountered a troubling issue when trying to pass it through a Java socket. Despite only passing bytes through the socket, the image always appears broken. The perplexin ...

Align images to the bottom of the gallery only if their heights differ

I'm currently working on an image gallery project and have encountered a problem. When all the image labels are of the same length, they align perfectly. However, if the label is longer than one line, it causes the image to move up instead of creating ...

Trick for hiding CSS elements when input field is vacant

Is there a way to hide the search result when the input is empty? While everything is functioning correctly, I would like to prevent the search result from remaining visible after clearing the input field. For example, if you type 'A' and then d ...

Resize the div blocks by scaling the button placed beneath them

I decided to modify the g-recaptcha widget to fit my specific requirements, and it is working flawlessly. However, I noticed that the ng-click button directly beneath it is no longer responsive. The reason behind this issue eludes me. Here is a snippet of ...

Expanding Headers with JavaScript

Looking to add a Stretchy Header Functionality similar to the one shown in this GIF: Currently, on iPhones WebView, my approach involves calling a Scope Function On Scroll (especially focusing on Rubberband Scrolling) and adjusting the Image Height with C ...

Instructions for creating a scrollable unordered list when it reaches its maximum capacity

My HTML code has a <ul> element with the following structure: <ul id="messages"> </ul> In my HTML file, I have not specified any <li> items. However, in my JavaScript code using jQuery, I dynamically add <li> items to the & ...

Tips for adding additional rows or cells to a table with jQuery

Similar Questions: How to Add Table Rows with jQuery Adding Rows Dynamically using jQuery. I am currently working with a table that contains one row and five editable cells for user input. My goal is to implement an "Add Row" feature using jQuery ...

Angular 7 - Customize Mat-select-value color depending on a specific condition

One issue I am facing is changing the color of a selected value in a mat select based on a condition. This change should be visually apparent to the user. Although accessing mat-select-value from the styles is possible, implementing a condition using ng-cl ...

What is the best way to combine two menu plugins in Wordpress?

Currently, I am in the process of creating a logo with a drop down menu for my website, which can be found at . After discovering a widget called Menu Image that successfully transformed a menu item into a photo, I decided to add another widget called Ma ...

Echo command fails to work with location.href

I am facing a small issue with my PHP echo. I have a JavaScript link function that is not working because the HTML code shows this type of link onclick="location.href="http://www.link.com/";". It's clear that this syntax won't work. However, if w ...

Unable to identify the Xpath selector for the "Account settings button" and "find my iPhone" features within iCloud

When trying to access my iCloud account settings and locate the "Find my iPhone" button on iCloud.com, I am encountering issues with my selectors. It seems like there are no frames on the page, but the Xpaths I'm using are not matching. Here are the ...

Having trouble displaying images on iPhone 6

I am facing an issue with the background image of one of my elements. The image loads perfectly on most devices such as iPhone 5, iPhone 5c, and Samsung Galaxy, but it does not load on iPhone 6, iPhone 6 Plus, and some iPads. Can anyone provide insights ...

What is the best way to access all of the "a" elements contained within this specific div?

Chrome websites are built using the following structure: <div class="divClass"> <a class="aClass"></a> <a class="aClass"></a> <a class="aClass"></a> </div> Utili ...

New Feature in Bootstrap4: Navigation Bar Alignment Shift to the Left

I need help aligning my links to the right side of the page I attempted to use mr-auto but it was not effective <body> <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top mr-auto mt-2 mt-lg-0"> <a class="navbar-brand" hre ...

Generate unique div elements randomly using jQuery and Javascript to populate a container

My website has a section that spans 100% width and is 450 pixels tall. This is the HTML structure... <section class="interactive-banner"> <figure></figure> </section> I am aiming for each 'figure' element to be 150 ...

Conceal an element from view upon clicking on it

Task at Hand : Implement a smooth element hiding effect upon clicking, similar to the behavior on this website , where the letter A fades away smoothly when clicked. Is it possible to achieve this effect using only HTML, CSS, and JavaScript? var t ...

What is the best way to load the contents of an HTML file into a <div> element without it behaving as an object?

Currently, I am importing an HTML file into a <div> in this manner: function load_content() { document.getElementById('content').innerHTML = '<object type="text/html" width="100%" height="100%" data="./content.html"></obj ...

Dealing with customized protocol responses in JavaScript

My web server is set up to return a response like: HTTP/1.1 302 Found message://ActualMessage While this setup works seamlessly for UI clients like Android and iOS, I'm faced with the challenge of handling this case on a web browser. For instance, ...

Utilizing jquery and ajax to submit a form seamlessly without the need to refresh the web page

I've been struggling to submit a form without refreshing the entire page. I integrated some source code that I found, but for some reason, it's not working! Here is the HTML form I'm trying to submit: <form method="POST" action="" name= ...

Is it possible to determine if a variable is unset using isset?

Currently, I am utilizing the following code snippet to verify if isset is not set. For instance: if(!isset($_REQUEST['search'])) { } else if(!isset($_REQUEST['submit'])) {} I would like clarification on whether !isset is considered ...