Polka Dot Background Pattern

Beginner

This tutorial is from open-source community. Access the source code

Introduction

In this lab, we will explore the basics of CSS programming and learn how to use CSS to style and format web pages. Through a series of hands-on exercises, you will gain a solid understanding of CSS syntax, selectors, properties, and values, and be able to create visually appealing and responsive web pages. By the end of this lab, you will have a strong foundation in CSS and be ready to take on more advanced web development projects.

This is a Guided Lab, which provides step-by-step instructions to help you learn and practice. Follow the instructions carefully to complete each step and gain hands-on experience. Historical data shows that this is a beginner level lab with a 100% completion rate. It has received a 100% positive review rate from learners.

Polka Dot Background Pattern

index.html and style.css have already been provided in the VM.

To create a polka dot background pattern, you can follow these steps:

  1. Set the background-color property to black.
  2. Use the background-image property with two radial-gradient() values to create two dots.
  3. Specify the pattern's size using the background-size property. Use background-position to appropriately place the two gradients.
  4. Set background-repeat to repeat.
  5. Note that the fixed height and width of the element is for demonstration purposes only.

Here's an example HTML code for a div element with class polka-dot:

<div class="polka-dot"></div>

And here's the corresponding CSS code:

.polka-dot {
  width: 240px;
  height: 240px;
  background-color: #000;
  background-image:
    radial-gradient(#fff 10%, transparent 11%),
    radial-gradient(#fff 10%, transparent 11%);
  background-size: 60px 60px;
  background-position:
    0 0,
    30px 30px;
  background-repeat: repeat;
}

Please click on 'Go Live' in the bottom right corner to run the web service on port 8080. Then, you can refresh the Web 8080 Tab to preview the web page.

Summary

Congratulations! You have completed the Polka Dot Background Pattern lab. You can practice more labs in LabEx to improve your skills.