Today’s Goals:
- Finish border-radius and filter practice page
- Review CSS is the Best! spreadsheet
- Start learning about CSS blend modes
Today’s featured site:
- https://codepen.io/joshbader/pen/MZMzjr – This cute LEGO figure is created entirely out of CSS and JavaScript lets you can change its appearance
CSS Border-Radius Property
- The border-radius property lets you give elements rounded corners.
- Let’s play with the values in this example to see what smaller and larger numbers do to the corners.
- The border-radius property can take numbers (in pixels) or a percentage for its value (50% will create a circle).
- Border-radius is actually a short-hand property that will make all of the corners of an element the same. You can also use border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius.
CSS Filter Property
- The filter property gives fun visual effects to elements (often images).
- Let’s have a look at the different values here .
Your turn: image styling practice!
CSS Review
- The CSS we’re learning falls into one of two big categories: CSS layout and everything else
- This spreadsheet lists all of the CSS we’ve learned and includes links to code samples, definitions, use cases, and the names of your practice pages
- Coming up with CSS layout: display property, flexbox, grid
- Coming up with other properties: animations, buttons
CSS Blend Modes
- The background-blend-mode property blends background layers together (example: background image and background color).
- Let’s see what the background-blend-mode property values look like in action here . Let’s also play around with the values here .
- My example:
With background-blend-mode
Without background-blend-mode
- Your practice:
- You’re going to make a quote page using the background-blend-mode property to blend your background image with a background color.
- You will need to choose a quote, a background image to go with the quote, a background color, and a Google Font
- Tools:
Color: https://materialuicolors.co/ (or another color site of your choice)
Background image: pexels, unsplash, pixabay
Google Fonts: https://fonts.google.com/ - Skills practiced:
HTML: setting up webpage with correct HTML code in correct order (html, head, title, style, body, and div tags)
CSS: style content with color, font-family, font-size, background-image and color; use ID selector correctly for the wrapper
Graphic design: background image, use of color, typography - To do:
- Open Notepad++ and start a new page with opening and closing html, head, title, style, and body tags. Save as backgroundblend.html
- Title tag should say CSS Blend Mode Practice
- Add body, #wrapper, h1, and p selectors inside of the style tags in your head section. Put opening and closing curly brackets with each one and skip a space to add CSS later.
- Code check #1: click to view
- Go to the #wrapper ID selector in your style sheet and add margin: 0px auto; width: and height: (leave blank for now); background-color: (leave blank); and background-image: url(‘image name’); background-position: center; background-repeat: no-repeat;. You will need to add in the image name for your background image later (example: sky.jpg).
- Go into your body section and under the opening body tag add div id=”wrapper” and add a closing div tag just above the closing body tag.
- Code check #2: click to view
- Choose a background image from one of the sites above. Download a size between 1200-1900 pixels; nothing smaller or bigger. SAVE IT IN THE SAME LOCATION AS YOUR WEBPAGE!
- Type the background image name inside of background-image: url(‘image name’);. Example: background-image: url(‘sky.jpg’);
- Make the width and height in your wrapper match the width and height of your image. For example, if your image is 1800 x 700, make your wrapper width 1800px and the height 700px.
- Choose a background color for both your body and wrapper. They can have the same or different colors. YOUR BACKGROUND IMAGE WILL BLEND WITH THE BACKGROUND COLOR OF THE WRAPPER BECAUSE THE IMAGE IS DIRECTLY INSIDE OF THE WRAPPER. The body background color is the color you will see if your background image doesn’t quite fit your whole screen (no big deal).
Choose a color (or colors) that contrast with your background image. - Type or copy/paste your quote inside of h1 tags inside your body section.
- Type or copy/paste the image quote author’s name in paragraph tags below your h1. If you don’t know who said it, use Anonymous.
- Choose a color for your font and add it to your body selector. Example: color: blue;. Adding the color to your body selector will make the font the same color on your webpage rather than separately adding the color property to the h1 and p selectors (not necessary unless you want them to be different colors).
- Type text-align: center; to your body selector to center all of your text.
- Choose a Google Font. Click on one you like, copy/paste the link to the font-family in your head section right below your title tags and above your style tags, and copy/paste the font-family into the body selector.
- Choose a large font-size for your h1 (quote text) and a smaller font-size for your p (author name). Use the font-size property inside both the h1 and p selectors and make them different values.
- Optional but likely necessary to make text more readable: use the text-shadow property inside of your body selector to give all of your text a drop-shadow. Example: text-shadow: 2px 2px black; (you can change the size and color).
- Move your text down from the very top of the page by adding position: relative; to both your h1 and p selectors (any thoughts on why?). Then use the top property to push the text as far down the page as you want. For example: top: 100px; or top: 10%;
- Big, giant code check! click here
- Now is a great time to visually review your page before adding a background-blend-mode. Do you like the font-family? How does the color of your font contrast with the background image? Can you read it? If you can see the background-color of your body section, how does that look with the background image? Is your text too big or too small? Does the text need to come up higher or pushed lower? Make any changes you need to!
- Now add background-blend-mode: to your #wrapper selector and choose any value you want. This site is very helpful to see all of the values in action. Try them out and settle on one you like. For example: background-blend-mode: luminosity;