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

  1. 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.
  2. Download this file and place it in the "images" folder in your project portfolio.
  3. Create a new file in your project porfolio and name it splash.html. Copy the code from our project-template into it.
  4. Create a new file in your CSS folder and name it splash.css.
  5. If you don't have normalize in your CSS folder, download it from here and save it to your css folder.
  6. At the top of the splash.html there is a link for css/style.css. Change this to css/splash.css.
  7. Create a div as the first part of the body, and set the class as page-wrap

      <div class="page-wrap">
     
      </div>
    

  8. Create a ul as the first part of the page-wrap, and set the class to social.

  9. 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.

  10. Under the ul, create an H1 and an H2. Set the text of the H1 to your name, and the text of the H2 to a short statement about you.

  11. 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.

  12. Live preview! You should have a list on the page and two headings, plus the random text from HTML-Ipsum

  13. Open your css/splash.css.

  14. 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);
    }
    

  15. 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;
    }
    

  16. 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;
    }
    

  17. 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;
    }
    

  18. 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;
    }
    

  19. 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

  • 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?
  • 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