Enhance the hover effect of the <li> tag with CSS styling

Having difficulty setting the hover height of my <li> tag. Below you can find a link to my jsfiddle with the HTML and CSS code. Any assistance would be greatly appreciated!

Link to my menubar jsfiddle

Here is the HTML code snippet:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Home</title>
   <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
   <div id="logo">

   </div>
   <div id="navigation">
      <ul>
        <li id="left"><a href="#home">Home</a></li>
        <li id="left"><a href="#home">About Us</a></li>
        <li id="left"><a href="#home">Events</a></li>
        <li id="left"><a href="#home">Contact Us</a></li>
        <li id="right"><a href="#home">Login</a></li>
      </ul>

   </div>
   <div id="imgbanner">

   </div>
   </body>
   </html>

This is the CSS code snippet:

#logo {
   border-bottom: 2px solid black;
   width: 100%;
   height: 100px;
}

#navigation {
    background-color: #fff;
    border: 1px solid #dedede;
    border-radius: 4px;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.055);
    color: #888;
    display: block;
    margin: 0;
    overflow: hidden;
    width: 100%; 
}

#navigation ul {
    list-style-type: none;
    margin: 0;
    padding: 0;

}

#navigation li {
    display: inline;
    /*padding: 20px;*/
    -webkit-transition: all 0.2s;
    -moz-transition: all 0.2s;
    -ms-transition: all 0.2s;
    -o-transition: all 0.2s;
    transition: all 0.2s; 
 }

 #navigation li:hover {
    background-color: rgb( 251,184,41);
/*  padding: 20px;
*/
}

#navigation a {
    color: #026475;
    display: inline-block;
    line-height: 56px;
    padding: 0 24px;
    text-decoration: none;
}

/*#imgbanner {
   position: absolute;
   border: 2px solid black; 
}
 */
 ul #right {
    float: right;
 }

li #right{
    float: left;
}

After running this code, I am able to hover over both <li> tags but notice that the height differs for the last one.

Answer №1

Check out the updated code snippet: http://jsfiddle.net/eve8nsau/1/

modify

#navigation li {
    display: inline;
    ...

to

#navigation li {
    display: inline-block;
    ...

you might see a slight gap between list items, but you can eliminate it using different methods as discussed on Stack Overflow


Preview (on hover)

Answer №2

It seems odd to only apply "float: left" to the final <li>. My suggestion would be to modify it like this:

 li {
     float: left;
 }

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

Display temporary image until real image loads within ng-repeat angularjs

I am looking to display a placeholder image while the actual image is being loaded. I have tried using the ng-image-appear plugin. The issue I'm facing is that the placeholder image does not appear for img elements inside ng-repeat, although it works ...

Ways to adjust the visibility of the table of contents based on varying screen sizes

I am currently using a JavaScript code to dynamically generate a table of contents from H2 tags, and it's working flawlessly. However, I would like the table of contents to have a status of "Hide" (requiring clicking on "Show" to display the table of ...

What is the best way to extract data from a textarea HTML tag and store it in an array before iterating through it?

I have a project in progress where I am developing a webpage that will collect links from users and open each link in a new tab. I am using the <textarea> tag in HTML along with a submit button for link collection. Users are instructed to input only ...

`Inconsistencies between navbar hide and show toggling on smaller and bigger screens`

I've been experimenting with making my navbar collapsible using Flexbox. Initially, I was able to toggle the navbar correctly when the screen size is smaller. However, I encountered an issue where the navigation items do not reappear when I hide them ...

Revamp and Enhance Your Layout Using Bootstrap Cards

I am working with a bootstrap card and trying to control the visibility of the .task__content part using CSS transforms. Specifically, I want to hide it with transform: scaleY(0) and reveal it on hover over the .task element. However, I am encountering a s ...

What steps are involved in creating a mobile web app using Visual Studio 2012, jQuery, and ASP.NET MVC?

As a beginner in asp.net, I am tasked with creating a mobile web app project. Before diving into development, I would like to first focus on designing my app. Can anyone provide guidance on how I can achieve this? Any help is appreciated. ...

Unable to accept the link ID in the modal

Presently, I am facing an issue with a modal that links a product with a customer and involves product discount calculations. The customer is automatically selected using the modal id, and the product is chosen through select options with a while loop. T ...

How can a table row be connected to a different frame?

I am currently incorporating jQuery into my project and I would like to have the table row link redirect to a different target frame. Here is the HTML for the table row: <tr data-href="home.html" target="content"><td><h3><center>H ...

"Enhancing your web development with the power of HTML 5

Hello, everyone! I am just starting to learn about HTML 5 and I'm excited to use it in Salesforce. I am curious to see how well Salesforce supports HTML5. If anyone has any tips or advice on using HTML5 in Salesforce, please help me out. Your assista ...

Various formatting options on GitHub Pages

As a beginner in programming, I recently deployed my first project to github pages. However, I am facing two issues: While the desktop version of the site looks perfect, the cards on the home page appear unseparated on mobile and iPad devices. Despite try ...

Button failing to align properly in the center position

I was able to successfully create a responsive input box, but for some reason, the button is not aligned in the center. Below is the CSS code: .webdesigntuts-workshop button { background: linear-gradient(#333, #222); border: 1px solid #444; border- ...

Generating a Table with automatic width using the <td> tag

Allow me to clarify my thoughts. I am aiming to accomplish the following: I want to construct a table with 4 columns and multiple td (rows). However, I require each row to adjust its column width automatically based on its content. Typically, the size ...

Increase the thickness of the scrollbar track over the scrollbar thumb

I've come across several discussions on making the track thinner than the scrollbar thumb, but I'm looking to do the opposite. Is it possible to have a scrollbar track that is thicker than the scrollbar thumb? ...

Creating a Circular Design with Text at the Center Using CSS

I'm facing a challenge with this https://i.sstatic.net/zQiF8.png The alignment of the icon is off. I would like to adjust it slightly upwards for better presentation. Below is my HTML (angular): // Icon component <div> <i><ng-c ...

Issue with locating css and js files in Laravel 6 (net::ERR_ABORTED 404 (Not Found))

While everything works fine when I use the Laravel development server (php artisan serve), I encounter a 404 error when attempting to use XAMPP server for the Laravel auth login and register pages. I typically use href="{{ asset('css/app.css') } ...

Is there a way to incorporate my personalized styling and HTML code into Django forms?

I've been struggling to customize form styling in Django. I want to exclusively use my own styles for the forms. How can I achieve this? <form id="contact" action="" method="post"> <div class="row"> ...

One-of-a-kind Design: Linear Gradient Background Image

Can you help me with Linear Gradient? Is it feasible to incorporate an actual image instead of just displaying a color like #000000 or #ffffff? background-image: -webkit-linear-gradient(30deg, #000000 50%, #ffffff 50%); In the scenario mentioned above ( ...

restructure the HTML based on a jQuery condition

Using jQuery to Refresh HTML Content function(data) { if(data === "importtrue") { $('#rebuildme').//function like .html } else { $('#rebu ...

Match the text within a span with the .btn class

I am currently dealing with the .card displayed below and struggling to get the text "You liked this." to align correctly with the Like and Comment .btn-links under the hr element. <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bo ...

In order to design a v-btn-toggle with vertically aligned buttons, rather than horizontally

I'm currently in the process of developing a quiz using VueJS and Vuetify. My challenge lies in organizing the answer options vertically for the user to select. I attempted to utilize the v-btn-toggle component, but encountered an issue where the butt ...