Drawing a grid using CSS

前端 未结 7 2029
青春惊慌失措
青春惊慌失措 2021-02-07 00:20

I\'m looking for a way to draw a grid (i.e. http://www.artlex.com/ArtLex/g/images/grid.gif) inside of a div, using CSS (and JS if necessary). It feels like it should be relative

相关标签:
7条回答
  • 2021-02-07 01:23

    Here is a simple CSS-only solution, using linear gradients:

    html, 
    body,
    .grid {
        height: 100%;
        width: 100%;
        margin: 0;
    }
    .grid {
        background-image:
          repeating-linear-gradient(#ccc 0 1px, transparent 1px 100%),
          repeating-linear-gradient(90deg, #ccc 0 1px, transparent 1px 100%);
        background-size: 71px 71px;
    }
    <div class="grid"></div>

    0 讨论(0)
提交回复
热议问题