6

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!

Phil
  • 157,677
  • 23
  • 242
  • 245
J. Jackson
  • 3,326
  • 8
  • 34
  • 74

2 Answers2

9

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!

J. Jackson
  • 3,326
  • 8
  • 34
  • 74
  • Sounds like an actual Sass problem. Check their issues log perhaps ¯\\_(ツ)_/¯ – Phil May 27 '20 at 23:59
  • I meant about it converting percentage values. They are perfectly valid values so it shouldn't be changing them – Phil May 28 '20 at 00:56
  • Ah I gotcha. Well I'm glad it's working now, I may look into why Nuxt doesn't like percentage values in the future. Thanks again! – J. Jackson May 28 '20 at 04:09
  • dude, you just saved my day. I would never find out what was causing this. What a werid behavior – Kos-Mos Mar 02 '23 at 21:03
0

This isn't just a Nuxt issue, this happens with create-react-app as well. Changing from opacity: 100%; to opacity 1; fixed my build issue.

This post saved me from having an aneurysm. So it most likely is a SCSS issue or a Netlify one.

evang
  • 13
  • 4