HTML Academy
Positioning the background relative to different borders
Frames and Backgrounds8/33
Back to the list of tasks
  • 1. Preparation
  • 2. Background Size, Step 1
  • 3. Background Size, Step 2
  • 4. Background Borders
  • 5. Background Cropping
  • 6. Multiple Background Images
  • 7. Positioning the background relative to different borders
  • 8. background-repeat: round
  • 9. background-repeat: space
  • 10. Outer Frame
  • 11. Rounding Corners, Part 1
  • 12. Rounding Corners, Part 2
  • 13. Frame Image: border-image-source
  • 14. Frame Image: border-image-slice
  • 15. Slicing Asymmetrical Images
  • 16. Frame Image: border-image-repeat, Part 1
  • 17. Frame Image: border-image-repeat, Part 2
  • 18. Frame Image: border-image-width
  • 19. Frame Image: border-image-outset
  • 20. Muffin’s Royal Frame
  • 21. Muffin’s Eco-Frame
  • 22. Muffin’s Round Frame, Part 1
  • 23. Muffin’s Round Frame, Part 2
  • 24. Challenge: The Sea Wolf
  • 25. Frames and Triangles, Part 1
  • 26. Frames and Triangles, Part 2
  • 27. Frames and Triangles, Part 3
  • 28. Creating an Arrow with a Frame
  • 29. Creating a Round Arrow with a Frame, Part 1
  • 30. Creating a Round Arrow with a Frame, Part 2
  • 31. Real-Life Triangles, Part 1
  • 32. Real-Life Triangles, Part 2
  • 33. Challenge: Jewelry Work
background-repeat: space
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

background-repeat: round

Two interesting, but little-explored values of the familiar property background-repeat, which is responsible for setting the background repeat property, are round and space.

The default property value of background-repeat: repeat simply repeats the background image across the entire width and height of the block. If parts of the repeating image do not fit within the width of the block, then they are simply cropped.

If you set the value to background-repeat: round, then the repeating images at the edges of the block will not be cropped, but will be evenly stretched or shrunk across the entire width and height to take up the remaining space.

By the way, background-repeat accepts two arguments as a value: one for the horizontal repeat mode and the other for vertical repeat mode. If you assign one parameter, then it will apply to both directions. For example:

/* Repeat the background using "repeat" horizontally and vertically */
background-repeat: repeat;

/* Repeat the background using "round" horizontally and "repeat" vertically */
background-repeat: round repeat;

Let’s try out the round repeat mode.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>background-repeat: round</title> <meta charset="utf-8"> <link rel="stylesheet" href="setting.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="portrait"></div> </body> </html>
CSS
.portrait { margin: 20px auto; width: 400px; height: 400px; background-color: #ffffff; background-image: url("img/muffin.jpg"); background-size: 150px; background-repeat: no-repeat; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. On line 8, change the value of the background-repeat property to repeat,
    2. and then assign the value repeat round,
    3. Then assign the portrait a width of 500px
    4. and a height of 450px.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.