Drawing a grid using CSS

前端 未结 7 2027
青春惊慌失措
青春惊慌失措 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:01

    This is how i'd do it:

    1) Make image of an L where each side of the L is the equal to one of your squares in the grid.

    2) set this as bg image of your div, repeat on x and y axis

    3) give your div a 1px black border on the top and right

    4) you have the desired effect!

    hope that helps

    Edit after seeing your no images comment:

    why not just use a table to make the grid (as you wont be able to do what you want without images) and overlay the table with an absolutely positioned content div?

提交回复
热议问题