#How to achieve this design?

43 messages · Page 1 of 1 (latest)

hard pine
#

i know its a messs and it hurts your eyes (i am a newbie)

floral forge
#

you placed a gradient to the body, a gradient to the div and a gradient to the background as it seems

floral forge
floral forge
hard pine
floral forge
#

i don't see no mistake in the way you got this styling

hard pine
floral forge
#

wouldn't go to js

#

i would just do a CSS animation

#

you can do positions on the gradient

hard pine
#

But it's a JavaScript practice as I am learning JavaScript and trying to make a basic project out of it.

floral forge
#

in that case, i would still prefer the use of CSS, you anyway have to use CSS with javascript to make it.

#

CSS will just make your life easier

#

like if you got a real case personally i would prefer using CSS and finishing in 5 minutes rather than JS and having to think about logic and how to do the animation (around 30 minutes for me)

hard pine
floral forge
floral forge
#

also i don't see no toggle in the example you showed us..

#

sooo

#

is your toggle a click?

hard pine
floral forge
#

yes

#

alright

#

you can add the click toggle with JS

hard pine
floral forge
#

click listener*

#

and change the class

#

yeah

#

now make a gradient animation

#

and assign it to the active class

#

and i recommend adding the class not toggle-ing it because you will have to put the non animated on the standard class

hard pine
#

I am doing that, but why is it already applying the gradient? I want to apply the gradient when I click it, and I also want to change the gradient of the main box and the body to the same gradient as the button clicked.

hard pine
floral forge
#

if you put the non animated gradient on class1

#

and then add and remove class2 with a toogle, you can add the gradient animation to class2 and skip having to re-write the whole gradient + you won't have to write the gradient x2 times incase of a change

#

😄

hard pine
#

i updated the github take a look