CSS Backgrounds, Borders, and Images Modules Flashcards
Have a background image completely fill the container, even if you have to stretch the image
background-size: cover;
Have a background image completely display in the container, even if it leaves some empty space
background-size: contain;
Place a background image so it bleeds to the edge of the box, regardless of padding or border.
background-origin: border-box; // also: padding-box; content-box;
What’s the syntax for using multiple background images?
background-image: url(top.png), url(middle.png), url(bottom.jpg);
how is background-origin different than background-clip?
Both control how image displays relative to border, padding, or content box. Clip controls painting and origin controls placement.
Create a shadow that doesn’t extend to ends of the shape – make it inset by 5 or 10px on right and left.
box-shadow: 0 20px 10px -15px; // negative spread creates this effect
Create a linear gradient with three colors and set change points
background-image: linear-gradient(white 20%, yellow 40%, blue 90%;
What prefixed only (as yet) property lets you control image size of background images?
image-set: url (small.jpg 1x, medium.jpg 2x);
What are two ways to have a blue/yellow gradient extend from bottom to top?
linear-gradient( to top, blue, yellow) or (0deg, blue, yellow); or just 0, blue, yellow without deg.
Repeat a gradient of vertical lines across container
background-image: repeating-linear-gradient(90deg, black, black 10px, white 10px, white 20px);
Add a variable for a main color to root element, use the variable.
:root { –color: #efefef; };
color: var(–color);
What is the default background-clip and what does it mean in terms of backgrounds and borders?
default is border-box, meaning background color extends under the border, which is an issue with transparent white over white or dashed white over white.
How could you create a fat outline around text using text-shadow?
Use commas to create multiple shadows on left, right, top and bottom; add additional shadows to extend the outline (each with an increasing offset).
How can you create a single dot using linear gradient, and how might you turn it into a line?
background-image:linear-gradient(red, red);
background-size: 100% 1px;
background-repeat: no-repeat;
background-position: 4px 100%;