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

浪子不回头ぞ 提交于 2021-02-09 08:28:00

问题


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!


回答1:


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!



来源:https://stackoverflow.com/questions/62054132/nuxt-compiles-css-opacity-at-1-instead-of-100-when-deployed-to-netlify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!