Tips for altering font color on an overlay while hovering

Whenever I hover over the navigation links section, my overlay should display as a white section and the font color needs to change to white. Currently, the navigation does show a white section overlay on hover, but changing the font color has been elusive. I would also like to shift the overlay downwards, which is proving challenging.

<body>
  
  <div class="header">
      <div class="top-line">
        <h5>Buy now & pay later with Afterpay</h5>
      </div>
   </div> 
    
    <div class="container">
 
 <div class="info">                    
        <div class="left">
          <img src="https://i.ibb.co/wsCyQ98/Coozy-Shoes-removebg-preview.png" alt="logo">
            
          </div>
        <div class="middle-side">
          <a href="#">Shoes</a>
          <a href="#">Sale</a>
          <a href="#">Our Team</a>
        </div>
        <div class="right-side">
          <a href="#">Account</a>
          <a href="#"><i class="fa fa-search" style="font-size:36px"></i>
          </div>
      </div>
      
      <div class="title"></div>

My attempts at selecting the anchor tag along with the .title class have not been successful as the anchor tags do not appear. Additionally, trying to move the overlay section down by setting the top property to 10px does not produce the desired effect.

.title {
      height: 150px;
background-color: white;
position: absolute;
top: 10px;
color: white;
width: 100%;
font-size: 25px;
      /*padding-top: 20px;
padding: 15px 0;*/
text-align: center;
z-index: -1;
transition: 0.8s;
        }

.container:hover .title, a {
z-index: 0;
color: black;
        }

Answer №1

For a more effective solution, I recommend incorporating JavaScript into your code.

Another important aspect of styling is to use the !important keyword at the end of an attribute value to override any default browser styles.

        const navbar = document.getElementById('navbar');

        function displayNavbar() {
            navbar.style.display = 'flex';
        }

        function hideNavbar() {
            navbar.style.display = 'none';
        }
        .info {
            position: relative;
            width: 100%;
        }
        img {
            width: 100%;
            height: 100%;
        }

        ul {
            display: flex;
            list-style-type: none;
            position: absolute;
            width: 100%;
            top: 0;
            left: 0;
            margin: 0;
            padding: 0;
            background-color: white;
            display: none;
        }

        ul a li {
            padding: 15px;
        }

        ul a li:hover {
            background-color: rgb(17, 17, 17);
        }

        a {
            text-decoration: none !important;
            color: rgb(255, 0, 234) !important;
        }

        a:hover {
            color: red !important;
            text-decoration: none !important;
            cursor: pointer;
        }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    
</head>
<body>

   <div class="info"><img id="back" onmouseout="hideNavbar()" onmouseover="displayNavbar()" src="https://img.freepik.com/free-photo/abstract-grunge-decorative-relief-navy-blue-stucco-wall-texture-wide-angle-rough-colored-background_1258-28311.jpg?w=2000" alt="logo">
        
        <ul id="navbar" onmouseover="displayNavbar()">
            <a><li>Home</li></a>
            <a><li>Products</li></a>
            <a><li>Profile</li></a>
        </ul>
    </div>

</body>
</html>

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

I am experiencing an issue where the Flex table is not displaying more than 50 rows

I am experiencing an issue where I can't scroll back up with the scrollbar. The table is dynamically filled with data from a database, and when it gets too long, I am unable to scroll back up. Any suggestions on how to solve this problem? If you need ...

The HTML5 Canvas application is currently experiencing difficulty rendering images on Internet Explorer 8 browser

I have developed an HTML5 canvas program that copies an image into a canvas object and changes the transparent background color of the image to blue. This program works correctly on Firefox and Chrome, but I am trying to get it to run on Internet Explorer ...

What could be causing my Next.js layout to re-render?

I currently have a basic root layout set up in Nextjs (app router) that displays a navigation bar and the child components underneath it. ROOT LAYOUT import "./globals.css"; import type { Metadata } from "next"; import { Inter } from & ...

Scroll bar in div that scrolls dynamically at the bottom

$('textarea').on('input', function() { var scrollHeight = parseInt($(this).prop('scrollHeight')); $(this).height(scrollHeight); $(this).prev('.Content').outerHeight(300 - $(this).outerHeight()); }); $(".Cont ...

Insert a variety of images onto the page at the exact position where the user has

Looking to create a script that selects a random image from an array and displays it at the current mouse position. Additionally, you can click elsewhere to add a new image, allowing you to cover the entire page with random cat images if desired. docum ...

NodeJS seems to be having trouble with external CSS files

My nodeJS project uses an external CSS file to style the HTML page. Here is how my file structure looks: ProjectFolder ----server.js ----index.html ----style.css This is how my server.js file looks like: var http = require('http'); var f ...

Tips for creating a nested div structure using JavaScript

I am facing an issue with my results object that includes data like Creation_date and approval_date. I have put the results in a loop in JavaScript and created nested divs. However, when I debug it, the divs are not nested as expected. Each one seems to ...

JavaScript code causing the page to freeze

I am attempting to track the movement of a dynamic div (which is animated using CSS3 animations) by continuously monitoring its position. To achieve this, I have implemented a loop utilizing while(true) as shown below: function detectCollision(){ ale ...

Adding new fonts to an Angular 2 web page

I am working on an Angular 2 application and I want to incorporate wrapbootstrap. However, I am facing an issue with the fonts (bootstrap, font-awesome, google) and I am not sure how to include them. While using the css file for wrapbootstrap, I am gettin ...

Experiencing difficulties with JSoup on Android for HTML parsing

I recently started working on a fun little project to scrape data (specifically XKCD comics) from the internet and display it on my phone. This is my first time delving into Android development, and since I'm not too familiar with Java, I'm keepi ...

A simple way to add a value from a select option into a textarea when there are several dropdown menus and select elements sharing the same

I have several divs with the same class names where I need to input a value from a dropdown menu into the textarea that belongs to the div where the select element is located. I want this function to work smoothly even with more than 10 divs, which is why ...

Switching over from an external style sheet to inline elements can be tricky, especially when it comes to integrating "dropdown" styles properly

I successfully created a stylish menu using a specific style sheet, but now I'm facing issues when trying to incorporate this menu into web pages with different style requirements. Realizing that loading the style sheet onto these new pages wreaks hav ...

CSS transformation on the go

Can anyone help me? I am trying to create an animation for a hamburger menu when checked and unchecked. I have managed to animate the menu, but I'm struggling with animating the left menu when transforming it to 0. &__menu { transform: transla ...

Is it possible for a div or any other element to apply "margin:auto" while allowing padding only for the text inside it, rather than specifying a fixed size or percentage?

When creating a new div and adding text to it, there are a few considerations. <div style="margin:auto;background-color:yellow;padding:10px;">text</div> Instead of the default 100% width, we can add padding around the text "text". To achieve ...

Error Authenticating AngularFirestore Login

Currently, I am in the process of setting up user login functionality on our website. The database successfully collects the email and password when users sign up, but I have been encountering difficulties with verifying the login credentials. For more det ...

What is the best way to eliminate the lower margin in the UI-Boostrap Angular Tab directive?

The ui.bootstrap.tabs directive, which can be found here, seems to have a default margin before displaying its content. https://i.stack.imgur.com/NECGA.png Here is the HTML snippet: <uib-tabset active="activeJustified" justified="false" id="tabSet" s ...

Achieve a Smooth Transition: Utilizing Bootstrap 3 to Create an Alert Box that Fades In upon Click and Fades Out

Incorporating AngularJS and Bootstrap 3 into my web app, there is an "Update" button that saves user changes. Upon clicking the "Update" button, I aim to trigger and display bootstrap's alert box with the message "Information has been saved," followed ...

Tips for combining text and variable outcomes in printing

I created a calculator that is functioning correctly and displaying results. However, I would like to include a text along with the results. For example: You spent "variable result" dollars in the transaction. Currently, the results are shown only after ...

Can integer values be stored in localStorage similar to JavaScript objects and retrieved without requiring typecasting?

After setting an integer value to a localStorage item: localStorage.setItem('a', 1) and checking its data type: typeof(localStorage.a) "string" it shows as a string. I then typecast it to an int for my purposes: parseInt(localStorage.a) My ...

Issue with formControlName in mat-select element

I am currently exploring different question types and attempting to implement a new one that involves a dropdown list with images. In order to achieve this, I am utilizing Angular Material. My goal is to display an image on the screen when a particular opt ...