The card's shadow effect is not functioning properly because the hover feature is not working correctly

I'm having an issue with getting the cards ('.card', '.card p' and '.card p:hover' classes) to darken their shadow upon hovering over them, unfortunately nothing happens. However, the hover function on the navigation bar is working perfectly fine. I am using JavaScript to make the navigation bar stick to the top of the window as you scroll. If anyone can spare some time to help me solve this problem, I would really appreciate it.

There is also another problem: When running the code in Chrome and maximizing the window, it becomes impossible to scroll all the way to the bottom (using Windows 10). If someone could help me fix this issue as well, I would be very grateful.

$(function() {
  // Stick the #nav to the top of the window
  var navigation = $('.navigation');
  var navigationHomeY = navigation.offset().top;
  var isFixed = false;
  var $w = $(window);
  $w.scroll(function() {
    var scrollTop = $w.scrollTop();
    var shouldBeFixed = scrollTop > navigationHomeY;
    if (shouldBeFixed && !isFixed) {
      navigation.css({
        position: 'fixed',
        top: 0,
        left: 0,
        marginright: 0
      });
      isFixed = true;
    } else if (!shouldBeFixed && isFixed) {
      navigation.css({
        position: 'relative',
        left: 0,
        marginright: 0
      });
      isFixed = false;
    }
  });
});
{
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0%;
  font-family: Helvetica;
}

.header {
  position: relative;
  left: 0px;
  right: 0px;
  top: 0px;
  font-size: 187%;
  text-align: left;
  padding: 1.5%;
  background-color: #cccccc;
  color: white;
  z-index: 1;
}

.card {
  position: relative;
  margin-right: 2%;
  margin-left: 2%;
  margin-top: 2%;
  margin-bottom: 2%;
  z-index: -2;
}

.card p {
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 15px;
  padding-bottom: 15px;
  transition: 0.3s;
}

.card:hover p {
  box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
  color: blue;
}

.navigation {
  list-style-type: none;
  position: relative;
  left: 0px;
  margin-right: 0px;
  width: 100%;
  top: 7.2%;
  background-color: #cccccc;
  box-shadow: 0px 3px 25px grey;
  z-index: 0;
}

.wrap {
  margin: 10px auto;
  background: #cccccc;
  padding: 10px;
  margin-left: 0px;
  margin-right: 0px;
  width: 100%;
}

.navWrap {
  height: 30px;
  width: 100%;
  z-index: 0;
}

.li a {
  float: left;
  display: block;
  text-align: center;
  padding: 1%;
  color: white;
  text-decoration: none;
  transition: 0.5s;
}

.li a:hover:not(.active) {
  background-color: #e6e6e6;
}

.active {
  background-color: #3399ff;
}

.active:hover {
  background-color: #80bfff;
  transition: 0.5s;
}

br.clearLeft {
  clear: left;
}
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<div class="header" ;>Hello</div>

<div class="navwrap">
  <div class="navigation" ;>
    <div class="li a" ;>
      <li><a class="active" href="#home">Home</a></li>
      <li><a href="#news">News</a></li>
      <li><a href="#contact">Contact</a></li>
      <li><a href="#about">About</a></li>
      <br class="clearLeft" />
    </div>
  </div>
</div>

<div class="card" ;>
  <div class="card p" ;>
    <p>
      Example text
    </p>

    <p>
      Example text 2
    </p>

    <p>
      Example text 3
    </p>

    <p>
      Example text 4
    </p>
  </div>
</div>

Answer №1

Your :hover is not functioning because you have applied z-index:-2 on .card, so it would be better to remove it.

I made some changes to your CSS and HTML code to tidy it up...

Stack Snippet

//<![CDATA[
$(function() {
  // Stick the #nav to the top of the window
  var navigation = $('.navigation');
  var navigationHomeY = navigation.offset().top;
  var isFixed = false;
  var $w = $(window);
  $w.scroll(function() {
    var scrollTop = $w.scrollTop();
    var shouldBeFixed = scrollTop > navigationHomeY;
    if (shouldBeFixed && !isFixed) {
      navigation.css({
        position: 'fixed',
        top: 0,
        left: 0,
        marginright: 0
      });
      isFixed = true;
    } else if (!shouldBeFixed && isFixed) {
      navigation.css({
        position: 'relative',
        left: 0,
        marginright: 0
      });
      isFixed = false;
    }
  });
});
{
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0%;
  font-family: Helvetica;
}

.header {
  position: relative;
  left: 0px;
  right: 0px;
  top: 0px;
  font-size: 187%;
  text-align: left;
  padding: 1.5%;
  background-color: #cccccc;
  color: white;
  z-index: 1;
}

.card {
  position: relative;
  margin-right: 2%;
  margin-left: 2%;
  margin-top: 2%;
  margin-bottom: 2%;
}

.card p {
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 15px;
  padding-bottom: 15px;
  transition: 0.3s;
}

.card p:hover {
  box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
  color: blue;
}

.navigation {
  list-style-type: none;
  position: relative;
  left: 0px;
  margin-right: 0px;
  width: 100%;
  top: 7.2%;
  background-color: #cccccc;
  box-shadow: 0px 3px 25px grey;
  z-index: 0;
}

.wrap {
  margin: 10px auto;
  background: #cccccc;
  padding: 10px;
  margin-left: 0px;
  margin-right: 0px;
  width: 100%;
}

.navWrap {
  height: 30px;
  width: 100%;
  z-index: 0;
}

.li a {
  float: left;
  display: block;
  text-align: center;
  padding: 1%;
  color: white;
  text-decoration: none;
  transition: 0.5s;
}

.li a:hover:not(.active) {
  background-color: #e6e6e6;
}

.active {
  background-color: #3399ff;
}

.active:hover {
  background-color: #80bfff;
  transition: 0.5s;
}

br.clearLeft {
  clear: left;
}
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>

<div class="header" ;>Hello</div>

<div class="navwrap">
  <div class="navigation">
    <div class="li a">
      <li><a class="active" href="#home">Home</a></li>
      <li><a href="#news">News</a></li>
      <li><a href="#contact">Contact</a></li>
      <li><a href="#about">About</a></li>
      <br class="clearLeft" />
    </div>
  </div>
</div>

<div class="card">
  <p>
    Example text
  </p>

  <p>
    Example text 2
  </p>

  <p>
    Example text 3
  </p>

  <p>
    Example text 4
  </p>
</div>

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

What are the steps to resolve a Fetch request issue with a Node.js server?

I am attempting to make a simple POST request using the fetch method. I am working on building a contact form using Vanilla Javascript, HTML, and CSS on the front end, while utilizing Node.js / Express on the backend. Take a look at my front end code: ...

Scheduled tasks on Google Cloud Platform's App Engine are failing to run over the weekend

I am facing an issue with running a cron job in my node/express application using the node-cron library. The application is hosted on Google Cloud App Engine. My aim is to automate sending emails every day at 9 AM, but the cron seems to only work from Mon ...

Embed PHP file

This is my first venture into website development using php. I thought I had come up with a clever way to include the css sheet based on the file location. One example is when I submit a form with this code: $root = '../'; function died($err ...

Display text tags only when hovering the mouse over the input area

I am currently utilizing the TextExt plugin for autocomplete functionality and tags creation. $('#keywords').textext({ plugins : 'autocomplete tags', itemManager: CustomItemManager, tagsItems: [{value:'a&ap ...

The Vuetify Jest button trigger fails to function properly despite utilizing a spy

Recently delved into the world of Vue.js and Jest to see how they interact. I watched some tutorials and then decided to give it a go myself, but ran into trouble with getting the trigger click to work. Within my component, I have a login button, which is ...

CSS Trouble with Stacking Order

Seeking assistance with my learning/practice journey, any help is greatly appreciated. Please feel free to point out errors or inefficiencies. I currently have four layers in place: .body .main .main-side .sidebar Here is the design I'm trying to r ...

Is there a way to display images from a secure HTTP URL that has been parsed using jsoup within separate listViews?

After running the code above, I now have an array list with URL images stored as objImages Element table2 = document.select("TABLE").get(1); Elements asWithName = table2.select("tr>td a[name]"); for (Element aWithName ...

The issue with HTML5 anchor download attribute for saving files cannot be resolved

When I use an anchor tag like this.. <a class="btn btn-download" href="https://www.anotherdomain.com/file.jpg" download="customname.jpg">Download</a> The file is downloaded as file.jpg instead of customname.jpg Interestingly, it works fine i ...

The collapse feature of Bootstrap 4 Navbar is unresponsive

Struggling with the Bootstrap 4 navbar collapse feature issue. In the mobile viewport, instead of collapsing, it displays items as a vertical list. Here is the code snippet: <html> <body> <!-- Navbar --> <nav class="navbar na ...

Using Beautiful Soup to scrape the web and populate a Python list with the data

I have been working on learning how to web scrape with Python and BeautifulSoup, but I am running into an issue. When I try to add scraped items to a new list, only the final entry in the relevant tags is being displayed when I print the lists. How can I m ...

Issue with floating right navigation functionality

Hi there, I'm experiencing a minor issue with the navigation on my website. When I hover over the right side of the nav bar, the drop down menu shifts slightly to the right. All other elements in the nav are positioned absolutely... nav { pa ...

Place the text below the adaptable div

Could anyone offer guidance on how to properly align text underneath responsive images within divs? The issue I'm facing is that the divs adjust smoothly based on the viewport size, but the text below them doesn't stay centered as intended. Whi ...

What is the meaning of '=>' in typescript/javascript?

I keep coming across lots of '=>' in the code I found on the internet. Could someone please explain it to me as if I were 5 years old? (I'm searching for the specific code, and I'll share it here once I locate it).. Found it: ...

Create dynamic HTML files using Express, EJS, and FS, and deliver them using Nginx as the server instead of relying

Imagine a scenario where we have a JSON object: [ { "id": 1, "title": "Title 1", "description": "Description 1" }, { "id": 2, "title": "Title 2", ...

Assigning a specific tag when utilizing ng-options in Angular

I'm struggling with setting the default value in a dropdown list using ng-option. Can someone take a look at my code and provide some guidance on how to resolve this issue? <div class="form-group"> <label c ...

What is the method to effectively conduct a testing procedure for JavaScript files that have been exported using

I have a JavaScript file called "sum.js" which contains a simple function: // sum.js function sum(a, b) { return a + b; } export default { sum }; Now I want to write a test for this file using Jest. Here is my "sum.test.js" file in the same folder: // ...

Issue with getting Bootstrap sticky-top to function on sidebar column

My goal is to implement a sticky sidebar on the right side of the page. The sidebar menu is contained within a grid column. I have attempted to utilize the sticky-top class, following the guidance provided in this question, but unfortunately, it does not s ...

Is it possible to arrange the contents within a textarea by both key and value using JavaScript?

In my html page, there is a textbox labeled "Type your text" and TextArea list. The goal is to enter text into the textbox and then click the Add button so that the content of the textbox gets added to the TextArea list below. The required format for input ...

Tips on transferring a Rails variable to Ajax

Struggling to integrate a progress bar (Javascript) into my Ruby on Rails application, I am facing difficulties in passing values from the controller to JS for updating the bar. In my initial attempt, I used a basic global variable ($count), but it remain ...

Using Promise.all() functions properly, but employing await on individual promises does not yield the expected results

My current code is designed to iterate over a list of objects representing files. Within the loop, there is a call to 'getRequest()' which returns type 'Promise<Response>', followed by a call to '.text()' which returns & ...