0
Moving elements
Hello I want to know how to move element based on its color for example when its green it stays at its place but when its black or red it goes Up in the page Using “HTML,CSS,JAVAScript”
7 Antworten
+ 2
Did you change color with animation or in javascript?
I think it is best to use javascript for it, because you can check current color, and when color is red than change position
+ 1
You can change position of elements.
Check this:
https://www.w3schools.com/css/css_positioning.asp
You didnt post code, so I dont know how color of element is defined, do you set it directly in css, or are color is changing on some click, animation..
You can also access color and background color in js and even change it, with "=" it set color without it can read color and store to variable.
https://www.w3schools.com/jsref/prop_style_backgroundcolor.asp
+ 1
The idea that im having is that the color randomly ( red, black,yellow, green)
So when its red or black the div change the div position goes up
+ 1
Can you provide your attempt?
+ 1
You never posted your code, so we dont know what exacly you are trying to do.
I posted some code where you can see some of this feature implemented, so you can figure out and use it in your code, ofcourse with changing to fit your need.
Please post your attempt, so we can understand better and help you, or if you dont know where to start look on some tutorial on internet (video will be best).
0
Here is my code where I moved element when it have red background, hope this will help you.
https://code.sololearn.com/WnD6IVP5c54S/?ref=app
0
Thank you but It did’t work
And your code keeps moving i want a one time movement
Note:my div has alot of divs in top of it