I’m wondering if someone can point me in the right direction to achieve the following;
I want an image in a link block to be black, then when you hover over the linkblock/image the background will change to e.g Orange then the image will change to white.
I know how to change the background colour but not sure how to change the image?
Hi @Matty yes that’s definitely possible to do in Webflow, I usually recommend creating a sprite for that kind of background image change as you’ll essentially change the background image position on hover to show the other image variant (white variant, vs dark variant).
Adding a background color change is quick and easy to do as well.
Thanks for the reply, with regards to the colour background is it possible to have it so when you hover over the “aboutbox” div it changes rather then hovering over the circle its self?
Sorry you completely lost me with sprite, is it not possible to do this in webflow itself? sorry to be a noob
@Matty - Hi there! Webflow can’t change the colours of pngs or jpegs - if you want the png icon to turn white when you over over it you will need a white version of the png. i.e. When you hover over the element, the black png would disappear and the white png would appear. I would set this up with Interactions on ‘iconbox’ using ‘Affect different element’
Create a white version of the icon in Photoshop and load as Image widget - give it a class name. This will sit on top of the black png.
(You will need to give the black and white pngs a class name each and set their Positions to ‘Absolute’ - this is so they sit on top of each other in ‘iconbox’)
Add an Interaction to the white png and set the Initial Appearance to 0% opacity.
Add an Interaction to ‘iconbox’ and use ‘Affect different element’ (select the white png class name) to then set the white png to 100% opacity
And in the same interaction, use ‘Affect different element’ (select the bacl png class name) and hide the black png (set to 0% opacity) - You can adjust the speed of these transitions to your liking (i.e. to match the transition speed of the background colour change)
You should also set the transition speed of ‘iconbox’ background colour change to something like 500ms so its a smoother transition from white to red. This may not be the best or only way but it’s how I’d do it! Hope you understand this and it helps! The main point is, you can’t change colours of pngs - you have to use two different pngs and transition between them using an interaction. Regards - Kai
Thanks for the detailed reply Kai, I will give this a go in the morning.
When you say give each icon a class, do you simply mean create a class for the image? not create a new div?
Also, is it possible to add more elements? as when the white image shows I want the “iconbox” background colour to change when you hover over main box div so the white image is visible.
When I thought about this idea it sounded much easier to do
Sorry…! As you know, when you add elements to Webflow you need to give them a class name so you can edit the settings - that’s all I mean by ‘give each image element a class’.
Both pngs will need Position set to Absolute:
You have already set the background to change to red - so this is ok - but I would slow this down by adding a 500ms transition to ‘Background Color’ under Transitions & Transforms.
These things get easier with practice! Regards - Kai
YES. I believe you will need to duplicate your iconbox(s) (iconbox_color1, iconbox_color2) and fade them in and out using the hover interaction transition tied to aboutbox, similar to what you did with imageWhite and imageGrey.
[EXAMPLE]removed
Hover over the box, changes the background of circle - hover the circle, changes the color of the star. I hope this helps …
@Matty - Hi there, you can’t change the background colour of a div with an interaction (unfortunately). If you want the background colour of ‘iconbox’ to change when you hover over ‘aboutbox’, you will have to add the red background colour (#d2036e) to the white png in Photoshop.
Then remove the red background hover state on ‘iconbox’ as this will now be redundant. Regards - Kai