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!
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With