The background values no one knows about
Kevin Powell
15 min, 28 sec
The video discusses two lesser-known CSS background repeat properties: space and round, and demonstrates their use with a star rating example.
Summary
- The speaker discusses the common use of 'background-size: cover' and the tendency to avoid repeating backgrounds in modern CSS design.
- Two CSS properties for background repeat are introduced: 'background-repeat: space' and 'background-repeat: round', which are not widely known.
- A practical example is provided, showcasing how to use the 'space' property to create a star rating system that adjusts the number of stars based on a selection.
- Browser support for these properties is excellent, and viewers are encouraged to share any use cases or production experiences with these properties.
Chapter 1
Chapter 2
The speaker introduces two little-known CSS properties for background repeat: 'space' and 'round'.
- Many seasoned CSS developers are unaware of the 'background-repeat: space' and 'background-repeat: round' properties.
- These properties offer additional control over how background images repeat and fill the space.
Chapter 3
A refresher on how repeating backgrounds work in CSS, including the basic repeat properties.
- Background images naturally repeat to fill the available space, cropping off as necessary.
- Control over repetition can be achieved with 'background-repeat: no-repeat', 'repeat-x', and 'repeat-y'.
Chapter 4
The speaker explains the 'space' property, which prevents cropping of images and maintains even spacing.
- Using 'background-repeat: space' ensures that the image is never cropped and is repeated with even spaces in between.
- As the space available changes, the number of images adjusts accordingly, without any cropping.
Chapter 5
The video discusses the 'round' property, which adjusts image sizes to fill the space without gaps.
- 'background-repeat: round' stretches or shrinks images to eliminate gaps and fill the space entirely.
- This property may distort the image, making it less practical than 'space' for certain use cases.
Chapter 6
The speaker demonstrates how to use the 'space' property in a practical scenario with a star rating system.
- A star rating system is presented, which dynamically adjusts the number of stars based on user selection.
- The 'space' property is used to ensure even spacing between stars without image cropping.
- Custom properties in CSS are utilized to calculate the width and spacing needed for the selected number of stars.
More Kevin Powell summaries
Incredible scroll-based animations with CSS-only
Kevin Powell
A guide to creating scroll-linked animations using only CSS.
A practical guide to responsive web design
Kevin Powell
A detailed exploration of strategies for writing effective and responsive CSS for modern web design.
Avoid these 5 beginner CSS mistakes
Kevin Powell
The video discusses common CSS mistakes made by beginners, with demonstrations and solutions.