Instructions for creating CSS3 Demo using Media Queries
Take the HTML5 template from the class website.
remove the <nav> and <ul> so only the <header> and <h1> are left.
Enter "CSS3 Exercise" in h1
Remove the <h2>, <p>, <figure> <img> and <figcaption> from the <article> tag.
remove the <footer> tag.
remove the <main> tag.
We will manipulate the HTML using only CSS styling.
Remove all the existing styles in the embedded style sheet.
Give the section —the holding container — 100px margins on top and left to push the content away from the ends, and position it relative, in case absolute position is used.
Give the header a 60 pixel margin at the bottom.
The article will be given the style that will change as we move the window. The default style is a 200px square with a background color and a 1px border, positioned absolutely.
Rename the h1 "CSS Exercise"
We want to annotate what we are doing and will use the pseudo element header:after to tack on the word plain and set it below the header using relative positioning.
and finally, to place a number 1 in front of "CSS Exercise" header, so it becomes easy to keep track of the numbers that we complete.
h1:before {content:"1. ";}
Now comes the fun part. We are going to make this responsive, so that as we pull it past 450px, the style of the <article> element and the description in the title will change.
First we make the @media block set to trigger at a window with greater than 450px: @media all and (min-width: 451px) {
}
Inside the @media block, we change the article using border radius to 50%. That turns a square into a circle.
article {border: 20px solid #666; border-radius: 50%;}
We want to change the description from plain to "border radius" header:after {content:"border radius";}
and finally, place a number 1 in front of "CSS Exercise" header to keep track of the number that we complete.
h1:before {content:"1. ";}
Go back to your document and move the page width beyond the 450px threshold, and you should see the square change.
You will be getting the different properties from the demonstrations on the website.
The procedure remains the same, with an incremental 50px jump with each new media query.
Notice that there is no need to repeat properties if they are already defined. There is only a need to overwrite properties that will change.
The next media query looks like @media (min-width: 441px) {
}
article { border-radius: 0% 1000%; }
h1:before {content:"2. ";}
You can do the remainder in class, or if we do not finish, for homework.