Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
Last active August 29, 2023 08:29
Show Gist options
  • Save carolineschnapp/63fd3c4327a466174aa8 to your computer and use it in GitHub Desktop.
Save carolineschnapp/63fd3c4327a466174aa8 to your computer and use it in GitHub Desktop.
CSS for Reveal module
/* ===============================================
// Reveal module
// =============================================== */
.reveal .hidden { display: block !important; visibility: visible !important;}
.product:hover .reveal img { opacity: 1; }
.reveal { position: relative; }
.reveal .hidden {
position: absolute;
z-index: -1;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
-webkit-transition: opacity 0.3s ease-in-out;
-moz-transition: opacity 0.3s ease-in-out;
-o-transition: opacity 0.3s ease-in-out;
transition: opacity 0.3s ease-in-out;
}
.reveal:hover .hidden {
z-index: 100000;
opacity: 1;
}
.reveal .caption {
position: absolute;
top: 0;
display: table;
width: 100%;
height: 100%;
background-color: white; /* fallback for IE8 */
background-color: rgba(255, 255, 255, 0.7);
font: 13px/1.6 sans-serif;
text-transform: uppercase;
color: #333;
letter-spacing: 1px;
text-align: center;
text-rendering: optimizeLegibility;
}
.reveal .hidden .caption .centered {
display: table-cell;
vertical-align: middle;
}
@media (min-width: 480px) and (max-width: 979px) {
.reveal .caption {
font-size: 11px;
}
}
@bbzhou
Copy link

bbzhou commented May 10, 2018

Hi I have tried this to my Debut themed store on shopify, everything works except the images appears stretched. All of my photos are squares, but somehow the photos that reveal after the hover are stretched as stretched rectangles. Please help :)

@jane2230
Copy link

Hello!) @harisbabic ; @heyjonmanning ; I have Brooklyn theme. Everything works great, I want to delete white background effect, but I can't find $opacity-link-hover in my SCSS at all, and it also does not change in line 30/31. Someone know how to change it and get rid of this background?
Jane.

@leojustrockit
Copy link

Hi @jane2230 I have found the location in Brooklyn theme. It is in line 3295.
&:hover,
&:focus {
opacity: 0.9;
@include transition(opacity 0.15s ease-in);
You could change the opacity to higher decimals or 1.

@directabe
Copy link

@leojustrockit
&:hover,
&:focus {
opacity: 0.9;
@include transition(opacity 0.15s ease-in);
You could change the opacity to higher decimals or 1.
like this ???

&:hover,
&:focus {
opacity: 0.1;
@include transition(opacity 0.15s ease-in);

@zackczj
Copy link

zackczj commented Jul 11, 2018

I am on a brooklyn theme, is this code outdated? My file is a scss.liquid file instead of css.liquid file.

Tried using this code, doesn't seem to work.

@whoischrislopez
Copy link

Hello, I am using the Debut theme on Shopify and have the product title and product price hover effect working with a few issues. The products are pushed down by invisible products that were not there before (reference image attached). The colored background is not vertically center aligned to the product and the background color only fills the height and width of the text and not the whole product itself. Can I get any help removing the space above products, vertically aligning the product title/price, and setting the height and width of the background color to match that of the product?

@sidyellur
Copy link

Guys I've been trying this on my Brooklyn theme for a week and it doesn't work! If anyone has managed to implement this on brooklyn theme, please HELP!

@saiancha1
Copy link

saiancha1 commented Aug 6, 2018

@Interfacehunt I used the debut theme and had to change the position of grid-view-item__image from absolute to relative in order for it to work. See if you can make the change in your theme.

Copy link

ghost commented Aug 10, 2018

@saiancha1 Hey, could you post the code in the final form that worked for you? What exactly did you change? I am also on Debut.

How did you set up the photos in the shopify admin for the photo to be displayed?

Copy link

ghost commented Aug 10, 2018

image

I have this issue - the slide bar on the right. How to get rid of it?

@AlbieGH
Copy link

AlbieGH commented Oct 11, 2018

Hello there! I'm trying the code on the Minimal theme, but when I add the extra code from the Shopify guide (https://help.shopify.com/en/themes/customization/collections/add-hover-effect-to-product-images), all the images disappear.
I am adding the extra code from the guide to my product-grid-item.liquid snippet, ...which looks a bit different from what's in the guide actually - I'll paste part of the snippet below.
The guide says I have to create a div class="reveal" around the img tag and then add <img class="hidden" src="{{ product.images.last | img_url: 'large' }}" alt="{{ product.images.last.alt | escape }}" /> right before the end of that div.
I tried adding the extra code both to the first img tag and to all 3 of the img tags I found on that product-grid-item.liquid snippet. The result is the same, the images disappear.
Any clue?

Here is a good portion of the product-grid-item.liquid snippet:

<span class="grid-link__image-centered">
        {% if featured.title != '' %}
          {% unless featured.featured_image == blank %}
            {% capture img_id %}ProductImage-{{ featured.featured_image.id }}{% endcapture %}
            {% capture wrapper_id %}ProductImageWrapper-{{ featured.featured_image.id }}{% endcapture %}
            {%- assign img_url = featured.featured_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}

            {% include 'image-style' with image: featured.featured_image, width: product_width, height: 480, wrapper_id: wrapper_id, img_id: img_id %}
            <div id="{{ wrapper_id }}" class="product__img-wrapper supports-js">
              <div style="padding-top:{{ 1 | divided_by: featured.featured_image.aspect_ratio | times: 100}}%;">
/*================ I added the div here and closed it correctly ================*/
                  <img id="{{ img_id }}"
                     class="product__img lazyload"
                     src="{{ featured.featured_image | img_url: '300x300' }}"
                     data-src="{{ img_url }}"
                     data-widths="[150, 220, 360, 470, 600, 750, 940, 1080, 1296, 1512, 1728, 2048]"
                     data-aspectratio="{{ featured.featured_image.aspect_ratio }}"
                     data-sizes="auto"
                     alt="{{ featured.featured_image.alt | escape }}">
              </div>
            </div>
          {% else %}
              <img src="{{ featured.featured_image.src | img_url: 'large' }}" alt="{{ featured.featured_image.alt | escape }}" class="product__img">
          {% endunless %}
          <noscript>
              <img src="{{ featured.featured_image.src | img_url: 'large' }}" alt="{{ featured.featured_image.alt | escape }}" class="product__img">
          </noscript>
        {% else %}
          {% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
          {{ 'product-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
        {% endif %}
      </span>

@madebymle
Copy link

Hi there, I am trying to use this update for the Cascade theme in Shopify and it is not working for me. Can you please tell me how I can get this to work for the Cascade theme?

Thank you!

@krittleb
Copy link

Does this code no longer apply? I am using Canopy theme and the only style sheet is styles.scss.liquid. I have added all of the code mentioned very carefully, and nothing happening. I turned off the "Quick Buy" option in Canopy theme thinking maybe it was conflicting as it puts a little banner on top of the main image, but still no go.

@josiahch
Copy link

josiahch commented May 23, 2019

The code no longer works on Brooklyn or just for me, any tip?

@jasonchosen
Copy link

image

I have this issue - the slide bar on the right. How to get rid of it?

Hello @domix90 did you ever get an answer for this?

@legrosbail
Copy link

Does this code no longer apply? I am using Canopy theme and the only style sheet is styles.scss.liquid. I have added all of the code mentioned very carefully, and nothing happening. I turned off the "Quick Buy" option in Canopy theme thinking maybe it was conflicting as it puts a little banner on top of the main image, but still no go.

Hi Krittleb , Did you ever manage to resolve the issue??? Trying to do this on my canopy.

Copy link

ghost commented Sep 9, 2019 via email

@Melongeek
Copy link

The original code is not working. This YT video works for debut theme on 2019.
https://www.youtube.com/watch?v=9uxSrOxxZpY

@affo98
Copy link

affo98 commented Aug 29, 2023

Hi, thanks for sharing your nice code. I was wondering if anyone has experience any problems with the hovering effect on safari. In a preview of my page, the hovering does not occur on Safari but on all other browsers. Why could this be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment