Forum Discussion

gjayne84's avatar
gjayne84
Brass Contributor
Apr 11, 2019

Web Part div change on hover

Hi everyone

 

Please bear with me as I'm fairly new to using SPFx and apologise in advance if this is an obvious question :-)

 

I have created a simple web part, which consists of a single div displaying a coloured circle.  A user can configure this to add text and a URL that the circle will link to.  However, I now want to add a bit of effect to the circle so that when the user hovers their mouse over it it gets slightly bigger and the colour of the circle changes.

 

I've created two CSS classes for the circle; one 'normal' and one for when the user hovers over it.  However, I'm not quite sure what code I would need to add to get the on hover function to work, and where I would add it.  I'm using the React framework.

 

I'd be grateful for any pointers from anyone.  Thanks in advance.

  • gjayne84 I'm not 100% sure I am following, but if you have the CSS classes, you would need to add them to the .scss file for your solution and add those to the className attribute on your React Component HTML.

Resources