What steps should I take to correct the hover issue?

https://i.sstatic.net/mOp5G.png

The hover effect does not cover the entire height of the link. How can I fix this issue?

I am aware that the color combination is not correct, but it's only for testing*

I am currently using Bootstrap 4.3.1

.navbar .collapse ul li{
} 
.navbar .collapse ul li a{
    font-family: 'Comfortaa', cursive;
    font-size: 20px;
    color: skyblue !important;
}
.navbar .collapse ul li a:hover{
    background-color: deepskyblue;
    height: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
    <a class="navbar-brand mx-5" href="#">
        <img src="Resources/Images/bootstrap-solid.svg" width="30" height="30" alt="">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto mx-3">
            <li class="nav-item active">
                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">News</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Services</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Contact</a>
            </li>
        </ul>
    </div>
</nav>

Answer №1

The padding from the .navbar class in your first div is causing the hover effect to not display correctly.

SOLUTION: To fix this, remove the top and bottom padding by incorporating the following CSS

.navbar {
    padding: 0 1rem;
}

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

Top Method for Incorporating Syntax Highlighting into Code Blocks - React Sanity Blog

I'm currently exploring the most effective method to incorporate syntax highlighting into my react sanity.io blog. Here's a look at the article component I've developed using react: import React, {useEffect, useState} from "react"; import ...

Instructions on how to access multiple modals on a single page

I am struggling to make two buttons open one modal and two other buttons open a different modal. Can you please help me figure out why the second modal keeps opening instead of the one I want? Each button has a unique ID generated from a MySQL database, ...

Incorporating unique typography onto your website (HTML/CSS)

I am currently struggling to implement a custom font on my website. I'm not very experienced with programming, and since my friend isn't available to help, I'd appreciate a solution from anyone. The issue I'm facing is that while the Ca ...

Incorporating External Content into Your HTML Website

Looking to incorporate third-party content in the form of an HTML page within my own website, I considered utilizing iframes. This would allow me to embed the external HTML page within my site while keeping their libraries and CSS separate from mine. Howe ...

What is the best way to achieve a sophisticated layout using the flex grid in CSS3?

Looking to achieve a responsive layout using flex without the need for media queries. Can anyone provide the CSS code for a layout using flex or grid? I've attempted the following: .parent { display: flex; flex-wrap: wrap; height: 100vh; } ...

Show an <input /> element when a <div> is transitioning

My current configuration is as follows: .wrapper { height: 40px; width: 80px; border-style: solid; border-width: 2px; border-radius: 40px; border-color: red; display: flex; align-items: center; justify-content: center; } .element { ...

What is the best way to position my menu icon and header text in alignment?

I’m having trouble aligning the menu hamburger icon and title on my website. I’ve tried various methods like wrapping them in a div and using display:inline-block, but they still won’t align properly. Can anyone provide guidance on how to achieve thi ...

Slick Slider isn't compatible with Bootstrap Tab functionality

I'm having an issue with using slick slider within a Bootstrap tab menu. The first tab displays the slick slider correctly, but when I switch to the second tab, only one image is shown. How can I resolve this problem? <!DOCTYPE html> <html ...

Styling definition lists and background containers with CSS

Currently, I am attempting to enclose a series of elements within a box and showcase some text beneath it: <div class="ft_models"> <dl> <dt>Models:</dt> <dd> <div>Item 1</div> ...

CSS animations are functional on Safari and Firefox, however, they may not work properly on Chrome

The code snippet below triggers the animation specifically designed for Firefox #rocket { position: relative; top: 10px; -webkit-animation-name: rocketLaunch; animation-name: rocket-launch; -webkit-animation-duration: 5s; animation ...

The browser automatically breaks up words at a hyphen when wrapping text

Here is an h2 element: <h2>ENHANCE YOUR DIGITAL FOOTPRINT WITH PERSONALIZED E-COMMERCE</h2> While it displays correctly in Firefox, the word E-COMMERCE gets split into two words in IE and Chrome when the HTML is rendered. How can I resolve th ...

What is the method for specifying the HTML file extension within Visual Studio?

I am having issues with my project recognizing the CSS and other files in the HTML files I have created, even though I have double-checked the extension paths. How can I resolve this problem? https://i.stack.imgur.com/85ooE.png https://i.stack.imgur.com/F ...

Thymeleaf: Automating the Adjustment of Content Fragments

In my project using Spring MVC and Thymeleaf, there is a default fragment that sets up the page structure. Here's what it looks like: <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/ ...

Troubleshooting an Issue with CSS Sliding Doors

I'm having trouble getting the right image to show on my website. The left side of the image is fine, but I can't figure out how to make the right one appear. As a HTML/CSS beginner, I'm still learning the basics. For more information, vis ...

In what ways can the accessibility of a website be impacted by using CSS

After reading numerous articles on Google and Stack Overflow, I have decided to ask my question straightforwardly in the hopes of receiving a clear and direct answer. Adding another layer to the discussion about whether Does opacity:0 have exactly the sam ...

Eliminate whitespace on the right side of a webpage using Bootstrap

I am currently working on a form that will appear in a modal, but I need it to be centrally aligned so that I can reduce the size of the modal. Here is what I have implemented so far: It seems like there is some space being "reserved" for columns that are ...

What could be causing the input submit in my form to be unresponsive when clicked?

I'm stumped on what's causing the issue. My sign-up form seems to be malfunctioning - when I click the "Complete Registration" button, nothing happens! The form doesn't even submit. Here is the HTML structure: <!DOCTYPE html> <html ...

Merge multiple list groups into one with a single active selection using Bootstrap List group functionality

Currently, I am experimenting with merging Bootstrap's accordion and list group with JS behavior. My goal is to create a set of list groups where only one option can be active at a time within each accordion. <link rel="stylesheet" href="https:/ ...

Tips on ensuring a div automatically adjusts its size to accommodate collapsed elements

I can't seem to find the article about this, so I'm not sure if it's been asked before. Currently using Bootstrap 4.3.1. I have a div with collapsed elements inside. Whenever I expand or collapse these elements, the div adjusts its size (n ...

Make sure your HTML content is optimized to fit on one page when printed

I'm currently using Swift along with a WKWebView to load HTML, establish the A4 page dimensions, and then save it as a PDF. (Though, I believe this is more of an HTML/CSS-focused question). The generation process looks like this: func generatePDF ...