You can use the images added here or (for full marks) you can search for your own on google. To add diferrent images you must:
Image search on google for facebook cover photos ( this is necessary because of the size of the image)
Press view image and copy the link from the browser
Paste the link here `src="link here"
The CSS part
Now that we’re done with the HTML, we need to add the CSS in order to create the animation.
So, first we have to create a stylesheet.css file in the same folder as the HTML file.
The first thing we will add in this file is:
body {
margin: 0;
}
This will make the body of the webpage have no margins as our aim is to stretch the cover photo across the screen.
The next important thing we need to add is the #cover_photo selector.
#cover_photo {
margin:0 auto;
color:white;
}
This will stretch the cover_photo div across the screen. (Only in width) color:white is only added to eliminate any extra text that might appear from the animations.
Next we have to add the animation that goes from opacity 0 to 1.
Important here is the width set to 100% which will ensure the photo stretches out to fill the web page width.
The max-height is set to 60% and the min-height to 30% for when the user changes the size of the browser.
2. (Part 1) Creating a cover photo
By Andrei Boscor
In order to create a cover photo we will be using
The cover photo will contain four images that will transition every few seconds.
We will achieve this using only CSS3 animations. (Does not work in Internet Explorer)
Live Demo
Click here to view a live demo
The HTML part
Now in the html you have you will add a few things.
We will first link the stylesheet in the
<head>
of the HTML.That will import the CSS animations. We will create the stylesheet file later.
Now we need to create the actual element which will contain the cover photo.
This will be a div tag.
The div tag will be placed inside the
<body>
tag. (Very important!)Now it’s time to add the images we want for the cover photo.
Inside the
<div>
tag we will add every image.You can use the images added here or (for full marks) you can search for your own on google. To add diferrent images you must:
The CSS part
Now that we’re done with the HTML, we need to add the CSS in order to create the animation.
So, first we have to create a stylesheet.css file in the same folder as the HTML file.
This will make the body of the webpage have no margins as our aim is to stretch the cover photo across the screen.
This will stretch the cover_photo div across the screen. (Only in width)
color:white
is only added to eliminate any extra text that might appear from the animations.These are added multiple times with slight modifications in order to assure browser compatibility (moz is for Mozilla Firefox, o is for Opera, etc)
Important here is the width set to 100% which will ensure the photo stretches out to fill the web page width.
The max-height is set to 60% and the min-height to 30% for when the user changes the size of the browser.
Every photo used will go through the 8 second animation of fading in and out.
Opening the html page in Google Chrome or Mozilla, we will now have a transitioning cover photo.
Next lesson
In the next lesson we will be adding a profile photo and are positioning your name on the cover photo.