Hey I have a Question. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hey I have a Question.

I had written a code in html css and js to move a box using buttons. I have a question that if I create a div in another div then why does the inner div come out of the outer div when we try to move it out of the outer div using the buttons? Why doesn't it stay in? I don't want ready made code but I just want someone to explain this to me. Here is the code: https://code.sololearn.com/W2ni45MOD4ZE/?ref=app

2nd Dec 2023, 10:41 AM
Web Developer AD
10 Answers
+ 3
1- if u dont want it to go outside of the div just add //left if(f>0) f--; and //right if(f>=widthof the div) f++; and //up if(t>0) t--; //down if (t<=height of div) t++; 2- on css add body{ user-selection:none; } to not select the text in the buttons 3- its better to use canvas for games
2nd Dec 2023, 12:28 PM
Med Yassine
Med Yassine - avatar
+ 3
Thank you Med Yassine for your answer. It helped me understand the problem.
2nd Dec 2023, 1:25 PM
Web Developer AD
+ 3
Here you will find something similar: https://www.w3schools.com/graphics/game_intro.asp
3rd Dec 2023, 3:37 PM
JaScript
JaScript - avatar
+ 2
Arjun Dawande That all you can learn in Sololearns game development with Javascript.
3rd Dec 2023, 4:26 AM
JaScript
JaScript - avatar
+ 2
JaScript but I am not able to find any course named game development with JavaScript.
3rd Dec 2023, 8:32 AM
Web Developer AD
+ 2
Arjun Dawande You go to section Learn, then click on selection above and click on „discover all courses“ to see all offered courses. Or click here: https://sololearn.com/learn/courses/le-gamedev-with-js
3rd Dec 2023, 9:42 AM
JaScript
JaScript - avatar
+ 2
I can see that in Sololearns app. Did you try that in the app or in the website?
3rd Dec 2023, 3:30 PM
JaScript
JaScript - avatar
+ 2
Maybe the course was old and is in the meantime deleted.
3rd Dec 2023, 3:33 PM
JaScript
JaScript - avatar
+ 2
Thanks JaScript
4th Dec 2023, 1:03 AM
Web Developer AD
+ 1
Hey JaScript I clicked on the link that you provided but it is taking me to the Angular course which I have already completed. I also tried to find it in the discover all courses option but that course is not there. I think they have removed that course.
3rd Dec 2023, 3:02 PM
Web Developer AD