- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Hover on Image with CTA
SOLVEJan 21, 2020 5:23 PM
Hi there,
I am trying to edit my image/cta module so that it hovers and displays a CTA. However, I can't seem to get the code right - the hover/cta itself is appearing below the image. I've looked at various resources but my case is so unique, I'm not sure what code to edit. If anyone has any suggestions, I would be very grateful! Thank you 🙂
Link: https://learn.barcoding.com/?hs_preview=qcfzgXQe-24664026644
Image/CTA module code:
{% if module.target == true %}
{% set target = "_blank" %}
{% else %}
{% set target = "_parent" %}
{% endif %}
{% unless (module.link is string_containing "//") or (module.link is string_startingwith "/") or (module.link is string_startingwith "mailto") or (module.link is string_startingwith "#") or !module.link %}
{% set link = "//" ~ module.link %}
{% else %}
{% set link = module.link || "" %}
{% endunless %}
{% linked_image
label="Linked Image",
src='{{ module.img.src }}',
alt='{{ module.img.alt }}',
width='{{ module.img.width }}',
height='{{ module.img.height }}',
link='{{ link }}',
target='{{ target }}',
open_in_new_tab='{{ target }}',
size_type='{{ module.img.size_type }}',
max_width='{{ module.img.max_width }}',
max_height='{{ module.img.max_height }}',
cta guid="{{ module.cta_field }}",
%}
<div class="resource-box {{ linked_image }}">
<div class="resource-inner">
<div class="res-boximg bgimg-set" style="background-image: url('{{ linked_image }}')">
{% if linked_image %}
<div class="resource-imgbox" style="background-image:url({{ linked_image }})">
</div>
</div>
{% endif %}
{% else %}
{% endif %}
</div>
<div class="resource-Isocta">
{% cta guid="{{ module.cta_field }}" %}
</div>
</div>
</div>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Jan 21, 2020 9:10 PM
If you're wanting the entire element to be clickable I would forgoe using a Hubspot CTA and just using a link and text.
HTML + HUBL
{% if module.target == true %} {% set target = "_blank" %} {% else %} {% set target = "_parent" %} {% endif %} {% unless (module.link is string_containing "//") or (module.link is string_startingwith "/") or (module.link is string_startingwith "mailto") or (module.link is string_startingwith "#") or !module.link %} {% set link = "//" ~ module.link %} {% else %} {% set link = module.link || "" %} {% endunless %} <{% if link %}a href="{{ link }}"{% else %}div{% endif %} class="resource-box"> <div class="resource-inner"> <img src="{{ module.img.src }}" alt="{{ module.img.alt }}" width="{{ module.img.width }}" height="{{ module.img.height }}" class="resource-box-img" /> <div class="resource-box-cta"> <p class="button"> {{ module.text_field }} </p> </div> </div> </{% if link %}a{% else %}div{% endif %}>
CSS
.resource-box { display: block; } .resource-box-img { width: 100%; height: auto; } .resource-inner { position: relative; } .resource-box-cta { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #f38b00; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all 0.3s; transform: scale(0); } .resource-box-cta .button { background-color: white; padding: 1em 2em; border-radius: 5px; color: #f38b00; } .resource-box:hover .resource-box-cta { opacity: 1; transform: scale(1); }
Alyssa Wilie
Web Developer at LyntonWeb
If this answer solved your question, please mark it as the solution!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content