I don’t like my interface and would like to use this template instead. I would like for the image or video to load as the background image with slight movement.
(https://html5up.net/eventually)
What you are trying to create in many ways resembles the Ken Burns Effect: The Ken Burns Effect Using CSS Animations | kirupa.com You can apply this animation to your loaded image from the NASA API, and this will result in your image panning around slowly.
My initial reaction is that modifying existing templates is often a fair bit of work. Understanding how someone else structure the HTML and CSS may take as much time as creating something on your own. What are your thoughts on trying to extend your existing example to look more like the template?
I’ve been trying to do this for almost one week now and I just keep breaking my code. I’m trying to learn JS as much as possible, but this has me stumped.
If I can just get the image/video to display as the background, that would be HUGE!
You can set the backgroundImage property using JavaScript and set it to the URL of the image. Here is an example of how you can do this: Setting CSS Styles using JavaScript | KIRUPA
We are mimicking the CSS way of specifying the values and taking it directly to JavaScript. Let me know if this helps. I can create an example in a few hours after I send my daughter to school
No worries - what you are doing involves a lot of JS techniques! The first thing to notice is that when you view your output in the console, the request isn’t going through. The reason has to do with the value of choice:
Instead of passing in a date, what is being passed in is the actual HTML element instead. The way you pass in the date is by using the value property of the HTML element. What you have here:
Thank you so much! This worked!! You’re amazing! I’ll continue to play with the code but you helped me solve the hardest part. How long did it take for you to get this good with JS? I’ve only been learning JS on my own for 1 month. I can’t wait until I can decipher code like you!
JavaScript is not easy! For one month of learning, you are doing really well
One thing you can do is take a structured path towards learning JS starting with the basics and gradually going into more advanced topics. My content here may help (many articles have a video version as well): JavaScript 101 | KIRUPA
This content is almost a full / free version of my bestselling JavaScript Beginner’s Guide book, so there has been a lot of vetting and revisions that have gone into this content
As for how long it took me to get good enough with JavaScript? MANY many years! I started around 1998 with Flash, and its programming language was ActionScript. ActionScript and JavaScript share a lot of similarities, so that helped my transition into JS go a little smoother.
Creating engaging and entertaining content for designers and developers since 1998.