π» Project #3: Animated Movie Scene
Overview
π₯ CSS animations and transforms are powerful tools that bring life to web pages. With animations, we can create smooth transitions, moving objects, or even complex sequences of changes, making websites more interactive and visually appealing. Transforms allow us to manipulate elements by rotating, scaling, or repositioning them, enabling unique and dynamic designs.
In this project, youβll practice these techniques by building an animated scene inside a defined container. Youβll experiment with movement, resizing, and interactivity to make a creative and engaging display.
π§ BRAINSTORM: Look up on Google Images: βiconic scenes fromβ¦β + the title of your favorite movie, show, or book.
π₯ PROJECT SETUP & SUBMISSION INSTRUCTIONS
- Go to the public template repository for our class: BWL-CS HTML/CSS/JS Template
- Click the button above the list of files then select
Create a new repository - Specify the repository name:
CS1-Animated-Scene - Click
Now you have your own personal copy of this starter code that you can always access under the
Your repositoriessection of GitHub! - Now on your repository, click and select the
Codespacestab - Click
Create Codespace on mainand wait for the environment to load, then youβre ready to code! - π Write code in this Codespace during class.
Instructions
Part A: Setting Up the Starter Code
- Add Starter CSS Code
- Write the following style rules in
style.css:html, body { height: 100%; width: 100%; margin: 0; padding: 0; box-sizing: border-box; }These rules basically βresetβ the settings of the overall page.
- Write the following style rules in
- Set the Background
- Add a
bodystyle rule to include a background image:body { background-image: url("https://wallpaper.dog/large/20552168.jpg"); background-size: cover; }
- Add a
- Add the Scene Description Section
- Inside the
<body>tag inindex.html, create a container to describe the scene:<div id="scene-description"></div> - Inside that
<div>, include an<h1>element with the scene title and a<p>element with a brief description of the scene.
- Inside the
- Style the Scene Description
- In
style.css:#scene-description { width: 600px; margin: 20px auto; text-align: center; font-family: "Trebuchet MS"; font-size: 0.8em; color: white; }
- In
- Add the Scene Container Section
- Below the
#scene-descriptiondiv in HTML, add another container for the main animation area:<div id="scene-container"></div>
- Below the
- Style the Scene Container
- In
style.css:#scene-container { width: 600px; height: 400px; margin: auto; border: 5px solid black; background-color: white; overflow: hidden; /* contain objects "on-screen" */ }
- In
Part B: Building & Animating the Scene
- Plan your Scene
- Pick an iconic scene from a movie, TV show, or book that youβd like to model.
- Identify several possible animations to make your scene dynamic (e.g., a bouncing ball, flying objects, spinning elements, people walking, etc.)
- Add Elements to the Scene
- Inside the
#scene-container, add HTML elements to represent props, actors, etc. - For example:
<img id="actor" src=" ">for images/clipart<div id="ground"></div>for blocks/shapes<p id="ball">π</p>for emojis/symbols
- Inside the
- Style the Elements
- Define styles for the new elements to position and size them.
- Example styling for a
ptag that holds an emoji:#ball { display: inline-block; font-size: 30px; position: absolute; top: 20%; left: 15%; z-index: 5; }
- Define CSS Animations
- Use the
@keyframesrule to define the frames (βtimepointsβ) of an animation sequence. - Incorporate movement using
transformfunctions likerotate,scale,skew, andtranslatewithin your sequence.Reference: π W3Schools - Transforms
- Example:
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
- Use the
- Attach Animations to Elements
- In the selector for an object you want to animate, configure the
animationproperty.Reference: π W3Schools - Animations
- Example:
#ball { animation: spin 5s infinite linear; }Remember that this is shorthand for the 4 important sub-properties that control the settings of an animation:
animation-name,animation-duration,animation-iteration-count,animation-timing-function
- In the selector for an object you want to animate, configure the
- Test, Edit, Repeat!
- Ensure the animations are smooth and work well together, adjusting durations, iteration counts, and timing functions as needed.
There are other helpful, but optional, sub-properties like
animation-delayandanimation-directionavailable. Look them up! - You may also need to adjust your
@keyframesdefinitions to include more points (e.g.0%,25%,50%,75%,100%).
- Ensure the animations are smooth and work well together, adjusting durations, iteration counts, and timing functions as needed.
Minimum Requirement Checklist
- HTML Content:
- Include at least 6 HTML elements inside the
#scene-containerwith distinct classes or ids, using the appropriate tags (e.g.,<div>,<p>,<span>,<img>).
- Include at least 6 HTML elements inside the
- CSS Base Styles:
- Style all elements to fit your theme (e.g., colors, sizes, positioning).
- CSS Animations:
- Define at least 2 distinct
@keyframesanimation sequences. One of these must have more than 2 points in the animation sequence (e.g.0%,50%,100%rather than justfromandto). - In a selector for the element to be animated, specify the relevant animation properties (e.g.,
animation-name,animation-duration,animation-iteration-count,animation-timing-function, along with any optional customizations likeanimation-delayoranimation-direction).
- Define at least 2 distinct
- CSS Transforms:
- Apply at least 4 different
transformfunctions (e.g.,rotate,scale,translate).
- Apply at least 4 different
- CSS Positioning:
- Use at least 2 different positioning techniques (e.g.,
absolute,relative, orfixed).
- Use at least 2 different positioning techniques (e.g.,
- CSS Customization:
- Adjust the
backgroundof the movie scene, orborderstyles for visual appeal. - Ensure that the final product of your movie scene looks cohesive.
- Adjust the
Bonus Features
- Include an interactive effect (e.g.,
:hoverpseudo-class selector with atransitionproperty). - Use CSS variables for repeated values.
- Create a βstartβ
buttonthat triggers animations using aclasstoggle (requires some JavaScript). - Experiment with CSS
clip-pathorfilterfor advanced effects.
RESOURCES: While working on this project or attempting the bonus features, you are encouraged to look up any CSS properties on Google or π W3Schools, review our π Unit 1 Notes or π Unit 2 Notes, and make use of the helpful π¨ SheCodes CSS Tools.