How to make a grid (like graph paper grid) with just css?

后端 未结 4 566
北海茫月
北海茫月 2020-12-12 15:23

How to make a grid (like graph paper grid) with just css? I just want to make a virtual grid paper with only using CSS. Thanks in advance for the help.

4条回答
  •  执念已碎
    2020-12-12 16:07

    To make grids you can use CSS gradients, which work on all modern browsers (see Caniuse).

    Use linear gradients to draw a lined grid:

    body {
      background-size: 40px 40px;
      background-image:
        linear-gradient(to right, grey 1px, transparent 1px),
        linear-gradient(to bottom, grey 1px, transparent 1px);
    }

    Use a radial gradient to draw a grid with dotted corners:

    body {
      background-size: 40px 40px;
      background-image: radial-gradient(circle, #000000 1px, rgba(0, 0, 0, 0) 1px);
    }

提交回复
热议问题