...

Brick Style Background Patterns in Elementor and CSS

Sure, you can create background patterns quite easily using Elementor backgrounds for sections or containers. Simply upload an image, set it to repeat and use a custom size to scale it down. But what if you want to create a brick-style background pattern? For this, we will need a bit of CSS…

Scroll down to test this effect in an interactive exercise!

brick-style-background-pattern

How to create brick background pattern in Elementor Pro

First, remove any background image of your section or container in Elementor widget. We will be adding this background image directly in CSS.

If you are using Elementor Pro, go to ‘Custom CSS’ field in the ‘Advanced’ panel of your container or section widget and apply the code below.

selector {
    background-image: url('https://yourwebsite.com/your-image.png'), 
        url('https://yourwebsite.com/your-image.png');
    background-size: 100px 100px;
    background-repeat: repeat;
    background-position: 0 0, 50px 50px; 
}

Don’t forget to replace the URL with your actual image URL! This should be the PNG transparent image of one single pattern sample or pattern tile. You can also change the the background-size to anything you want and set the second set of values in the background-position property to half of that size.

How does this code work?

  1. We are setting two background images within the same background-image property. You can say that the first URL is for the the odd rows in the pattern, and the second URL is for the even rows. In our case, this is the same image, so we are using the same URL image source.
  2. Background-size is the size of the tile in the pattern. You can change this to anything you want.
  3. Background-repeat will create the actual pattern by repeating the tile in both horizontal and vertical direction.
  4. Background-position is where the magic happens and what creates the actual brick pattern. By using two sets of values separated by comma, we are defining the shift of the odd rows and even rows. The first two values represent the shift in horizontal and vertical direction of the odd rows. In our case, it is 0,0. The second set of values define the shift in horizontal and vertical direction of the even rows. In our case, half of the tile size, or 50px horizontally and 50px vertically.

How to create this effect with Elementor FREE

If you are using Elementor FREE, you can use the same code with minor adjustments.

First, apply a class to your container or a section. Go to the ‘Advanced’ tab and write the class name in the ‘CSS Classes’ field, without a dot. For example, you can name your class “bg-pattern”.

Don’t know what are CSS classes? Check out the post about CSS classes here.

Next, go to your CSS code – I am using Simple Custom CSS and JS plugin to write my CSS and type the code below. Note that we are using the same code as above, but instead of ‘selector’, we are typing our class name, this time called out with a dot (‘.’):

.bg-pattern {
    background-image: url('https://yourwebsite.com/your-image.png'), 
        url('https://yourwebsite.com/your-image.png');
    background-size: 100px 100px;
    background-repeat: repeat;
    background-position: 0 0, 50px 50px; 
}

Again, don’t forget to replace the URL with your actual image URL! This should be the image of one single pattern sample or pattern tile. You can also change the the background-size to anything you want and set the second set of values in the background-position property to half of that size.

That’s it! Now you’ve successfully created a brick style background pattern with seamless tiles using just a few simple lines of CSS in Elementor.

Try it out yourself!

Try to create this brick background pattern yourself using the interactive CSS exercise below!

Just click on the ‘CSS’ field in the CodePen below and type the CSS there to see the result. You can copy and paste the CSS codes from above and just change the background-size and background-position values to create different scaling effects.

See the Pen Brick background pattern exercise by Anait (@velvetmade) on CodePen.

Blog

Code Snippets

General Instructions

Step One: What I will be making

First click on the green ‘What I will be making’ button. This is how your end result should look like.

Step Two: What I need

Next, click on the ‘What I need’ button to get some basic parameters to use in the code. Such as the font family, colors, image URLs etc. These are just recommendations. Use your own judgement for the rest of the values, such as paddings, margins, spacing and size.

Step Three: Read the given HTML code

You don’t need to know how to write HTML for these exercises. However, you WILL need to take a look at the ‘HTML’ code in the exercise. You can switch from HTML to CSS tab in the Codepen screen. Then read the built HTML code for each exercise to understand the structure and find the classes that are defined for the elements that you will be editing. Use those predefined classes to style them in CSS.

Step Four: Click on the ‘CSS’ tab and start coding

Click on the ‘CSS’ tab in the Codepen screen and start typing your CSS code here, just below the ‘Write CSS code here’ comment. You can also delete this comment if you wish.

For example, if a ‘div’ has a class “text-content” in HTML, you can then style this class in CSS tab. Just don’t forget to add a dot before calling a class out (.text-content)

You should see a live preview of the CSS code that you are editing in the ‘Result’ tab to the right of the Codepen screen.

Step Five: Check the solution with the CSS code

If you are stuck, click on the ‘Show me the code’ button. This will reveal the code that you can also completely copy and paste in the CSS tab of the exercise to see the result.

Or you can just go back to the lessons and watch them again.

Have fun and feel free to reach out!

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.