Woodsy
October 22, 2024, 3:21pm
1
Hi, I have created a style field where I can change the numerical value so that I can change the style ‘bottom’ to move an image up or down by px.
<div class="hero__image-bottom" style="bottom: {{ module.style.hero_spacing }}px;">
When building out the content I get this view where I can add a value.
When I switch between desktop and mobile the number stays the same.
If you edit the style of a rich text module you can switch between mobile and desktop and add a seperate value to each.
How do I get this feature to work on a custom style field so that I can ad avalue for desktop and a value for mobile?
Thanks
Hi, @Woodsy Thanks for your question! I’d like to invite some of our community experts to the converstaion — hey @Jnix284 @BarryGrennan @dsmarion , do you have any feedback you can share with @Woodsy ?
Thank you very much! — Jaycee
Hi @Woodsy ,
HubSpot doesn’t currently support different style field values for mobile and desktop.
A workaround for your case is to create two separate style fields, one for desktop and one for mobile:
Hero Spacing (Desktop)
Hero Spacing (Mobile)
Then, instead of inline CSS, you can print it inside a {% require_css %} wrapper, for example:
{% require_css%}
<style>
/* Mobile */
.hero__image-bottom {
bottom: {{ module.style.hero_spacing_mobile }}px
}
/* Desktop */
@media (min-width: 768px) {
.hero__image-bottom {
bottom: {{ module.style.hero_spacing_desktop }}px
}
</style>
{% end_require_css %}
Woodsy
October 24, 2024, 6:04pm
4
Hi @GiantFocal that worked perfectly.
Thank you for taking a look.