Cover Sized Background Images
Lesson Number 22, October 17, 2014
Due For This Class
Lesson
- Review of Project #5
- Discuss different attributes for background images - in-class discussion
- Activity
Activity
- Go to pexels and find a background photo you want to use. Try to find something that you will be able to lay either white or black text over and there will be enough contrast for you to read the text.
- Download this file and place it in the "images" folder in your project portfolio.
- Create a new file in your project porfolio and name it
splash.html
. Copy the code from our project-template into it. - Create a new file in your CSS folder and name it
splash.css
. - If you don't have normalize in your CSS folder, download it from here and save it to your css folder.
- At the top of the
splash.html
there is a link forcss/style.css
. Change this tocss/splash.css
. Create a div as the first part of the
body
, and set the class aspage-wrap
<div class="page-wrap"> </div>
Create a
ul
as the first part of the page-wrap, and set the class tosocial
.Create at least two list items. Use Font Awesome to create social icons. Review step 5 in last week's activity if you forget how to do this.
Under the ul, create an
H1
and anH2
. Set the text of the H1 to your name, and the text of the H2 to a short statement about you.Hit enter a few times, and then go into the website HTML-Ipsum and copy the "Kitchen Sink" text. Paste it into your document. This is just to make the page longer.
Live preview! You should have a list on the page and two headings, plus the random text from HTML-Ipsum
Open your
css/splash.css
.At the top, create a CSS rule that will apply to the entire html document. Add a background image. The image will be the photo you downloaded from pexels.
html{ background-image: url(images/my-image.jpg); }
Live preview. What happened? Is your photo too big for your browser and you are only seeing a part of it? Or maybe your photo is too small and it's repeating. First, let's make it stop repeating.
html{ background-image: url(images/my-image.jpg); background-repeat: no-repeat; }
Now, position it. The position takes two attributes - one for x axis and one for y axis. We can use pixels, percentages, or just "top", "center", "left", "right" or "bottom". We will be using center center to position the background image in the center of our document.
html{ background-image: url(images/my-image.jpg); background-repeat: no-repeat; background-position: center center; }
Backgrounds can also be attached to the window - you can have them fixed in place, or you can have them scroll. We want ours fixed in place.
html{ background-image: url(images/my-image.jpg); background-repeat: no-repeat; background-position: center center; background-attachment: fixed; }
Now for the magic. Let's make this image fit in the space we have for it!
html { background-image: url(images/my-image.jpg); background-repeat: no-repeat; background-position: center center; background-attachment: fixed; background-size: cover; }
Let's live preview!
Homework
Project #6. Due Monday, October 27, 2014
- Important Note - part of this project is watching recorded videos about web design and development. Do not leave this until the night before.
CodeCademy
- CSS Selectors (Due Monday, October 27, 2014)
- Project: Sorting your Friends (Due Monday, October 27, 2014)
Start thinking about your content for your final project. We will be planning our final websites and starting to build them in the coming weeks, so while you do not have to submit anything based on these questions right now, it is important to start thinking about them / taking some notes for your own use.
- What content will you need to have?
- What content is already created? What will you need to create?
- Also start considering how you might lay out your content
- What will your menu items be?
- What pages will you need?
- What content will go on each page?
- How will people navigate through your website?
- What content will you need to have?
Read the following in White Space is Not Your Enemy. These chapters are short, but will help you immensely as you start to plan out and build your website.
- Chapter 2, pages 10 - 20
- Chapter 3, pages 21 - 30
- Chapter 4, pages 31 - 42
- Chapter 13, pages 214 - 236