Fluid width with equally spaced DIVs

前端 未结 7 1732
耶瑟儿~
耶瑟儿~ 2020-11-22 01:21

I have a fluid width container DIV.

Within this I have 4 DIVs all 300px x 250px...

相关标签:
7条回答
  • 2020-11-22 02:06

    If you know the number of elements per "row" and the width of the container you can use a selector to add a margin to the elements you need to cause a justified look.

    I had rows of three divs I wanted justified so used the:

    .tile:nth-child(3n+2) { margin: 0 10px }

    this allows the center div in each row to have a margin that forces the 1st and 3rd div to the outside edges of the container

    Also great for other things like borders background colors etc

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