Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue js Vue-cli performing "npm run build", compiles css for image opacity to 1%

Tags:

npm

vue.js

when I perform npm run serve everything work as intended.

when I perform npm run build there is "no error".

when I loot at the website the images can't be seen, then I inspect element I see the image opacity in my gallery section changes to 1%.

enter image description here

this is my template code:

<div class="gallery container">
  <div
    class="images"
    v-for="(image, index) in images"
    :key="index"
  >
    <img :src="image.small" @click="selectImage(index)" />
  </div>
</div>

My scss code:

 <style lang="scss" scoped>
    .gallery-wrapper {
      padding: 3rem 0;
      .gallery {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        align-items: center;
        .images {
          display: flex;
          justify-content: center;
          align-items: center;
          img {
            height: auto;
            cursor: pointer;
            width: 100%;
            opacity: 85%;
            border: 5px solid aliceblue;
            &:hover {
              opacity: 100%;
              transition: 0.5s;
              border: none;
              margin: 5px 0;
              box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
              width: 90%;
            }
          }
        }
      }
    }
    </style>

other images are working fine. only the gallery images changes opacity when performing npm run build.

I look at the dist folder it generated a class with 1% opacity.

build result dist/css/app.ae40bac8.css:

 .gallery-wrapper .gallery .images img[data-v-c5a51ec0] {
  height: auto;
  cursor: pointer;
  width: 100%;
  opacity: 1%;
  border: 5px solid #f0f8ff;
}
.gallery-wrapper .gallery .images img[data-v-c5a51ec0]:hover {
  opacity: 1%;
  -webkit-transition: 0.5s;
  transition: 0.5s;
  border: none;
  margin: 5px 0;
  -webkit-box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.62);
  width: 90%;
}

it seems the webpack generated the wrong opacity.

like image 308
Evan Avatar asked Dec 15 '19 22:12

Evan


1 Answers

Something that worked for me is using 0.85 instead of 85%

like image 70
urag Avatar answered Oct 21 '22 06:10

urag