Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt compiles CSS Opacity at 1% instead of 100% when deployed to Netlify

I have a Nuxt app that works great locally. When I deployed it to Netlify (where yarn generate was run automatically), I noticed that there were some odd CSS things going on.

I have a card with a hover effect:

<style lang="scss" scoped>
  .gallery-card {
    align-items: center;
    background: url('/backgrounds/image-1.jpg') no-repeat center center;
    background-size: cover;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 400px;
    justify-content: center;
    position: relative;
    max-width: 100%;

    .overlay {
      background-color: rgba(255, 255, 255, 0.3);
      bottom: 0;
      left: 0;
      opacity: 0%;
      position: absolute;
      right: 0;
      top: 0;
      transition: 0.2s all ease-in-out;
      visibility: hidden;
    }

    .gallery-title {
      color: white;
      text-shadow: 3px 3px rgba(0, 0, 0, 0.25);
      transition: 0.2s all ease-in-out;
    }

    .visit-btn {
      opacity: 0;
      transition: 0.2s all ease-in-out;
      visibility: hidden;
    }

    &:hover {
      .overlay, .visit-btn {
        opacity: 100%;
        visibility: visible;
      }
    }
  }
</style>

The hover effect works locally but not in production. Upon inspecting it in production, the elements underneath :hover are being given opacity: 1%; instead of opacity: 100%;.

Has this happened to anyone else, or does anyone have suggestions? Thanks!

like image 315
J. Jackson Avatar asked May 27 '20 22:05

J. Jackson


1 Answers

Thanks to @Phil for the answer. It's funny how your mind can immediately think it's got to be some complicated thing (I immediately thought it was some sort of Nuxt compile config), when in fact the simplest thing was the cause (using the Opacity property properly).

Solution

Change to opacity: 1; instead of opacity: 100%;

Doh!

like image 165
J. Jackson Avatar answered Oct 23 '22 04:10

J. Jackson