The background values no one knows about

Kevin Powell

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

Repeating Background Images in CSS

0:00 - 16 sec

Introductory remarks on the common practices and tendencies in using CSS background images.

Introductory remarks on the common practices and tendencies in using CSS background images.

  • Repeating backgrounds are often avoided in modern CSS design.
  • Designers typically use 'background-size: cover' to make images fill the space without repeating.

Chapter 2

Introduction to Obscure Background Repeat Values

0:16 - 20 sec

The speaker introduces two little-known CSS properties for background repeat: 'space' and 'round'.

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

Basics of CSS Background Repeat

0:36 - 24 sec

A refresher on how repeating backgrounds work in CSS, including the basic repeat properties.

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

Exploring the 'background-repeat: space' Property

1:00 - 2 min, 2 sec

The speaker explains the 'space' property, which prevents cropping of images and maintains even spacing.

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

Explaining the 'background-repeat: round' Property

3:02 - 3 min, 10 sec

The video discusses the 'round' property, which adjusts image sizes to fill the space without gaps.

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

Practical Example: Star Rating System

6:12 - 9 min, 17 sec

The speaker demonstrates how to use the 'space' property in a practical scenario with a star rating system.

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

Incredible scroll-based animations with CSS-only

Kevin Powell

Kevin Powell

A guide to creating scroll-linked animations using only CSS.

A practical guide to responsive web design

A practical guide to responsive web design

Kevin Powell

Kevin Powell

A detailed exploration of strategies for writing effective and responsive CSS for modern web design.

Avoid these 5 beginner CSS mistakes

Avoid these 5 beginner CSS mistakes

Kevin Powell

Kevin Powell

The video discusses common CSS mistakes made by beginners, with demonstrations and solutions.