This is a project I did to practice using CSS variables with Javascript. BirdWatcher simulates birdwatching by changing the position of "birds" on the screen as well as changing the focus of the "binoculars".
Preview: https://birdwatcher.netlify.app/
- Position: I leared much about different types of
position
. To move the birds around the screen, I set theirposition
toabsolute
and their parent container torelative
so that the birds moved relative to their parent. - JS: I learned how to control CSS variables using JS. I selected the root element of the DOM model (
documentElement
), chose itsstyle
and usedsetProperty('propertyName', 'propertyValue')
. - I also learned that
NodeLists
are not as powerful asArrays
.Arrays
have more functions you can use. - Grid and Flex: This is my first time using Grid. I used it to control the layout of the controls panel. I used Flex to make the overall layout of the page. Flex and Grid are powerful in their own ways and sometimes one is better than the other. Personally, I used Grid for the control panels because Flex would have required more
div
s. - Variables: Because the two birds are not meant to be stacked on top of each other, I used separate
top
andleft
values for each. Then, I stored those default values in the variables. I also usedfilter: blur()
on the bird images and stored the amount of blur in a variable. - Summary: I think CSS was more of a challenge than JS for this one. There were many concepts and properties involved. To get the binocular effect. I nested the background image inside of the
view
element and usedoverlay: hidden;
. - Potential Improvement: I also thought about fixing the birds on the page and moving the view window but it seemed too complicated for me at the moment.