how to make css background grid lines

Viewed 10726

img


There are four lines over the background. They are visible in overall sections but not over images.

How to make this?

2 Answers

You can use CSS linear gradients and multiple backgrounds to achieve this. Here's an example:

div {
  height: 100px;
  background-color: transparent;
  background-size: 25% 100%;
  background-repeat: repeat-x;
  background-image: linear-gradient(to right, black 1px, transparent 1px);
  background-position: 12.5%;
}
<div>
</div>

The gradient draws a vertical line, whereas background-size, background-position and background-repeat combined make the vertical line repeat.

Here's an example with a background image and the vertical lines:

div {
  height: 100px;
  background-color: transparent;
  background-size: 25% 100%, cover;
  background-repeat: repeat-x, no-repeat;
  background-image: linear-gradient(to right, black 1px, transparent 1px), url(http://lorempixel.com/400/200/);
  background-position: 12.5%, center;
}
<div>
</div>

Related