Advertisement
Udoro

Responsive 3 columns layout CSS

Nov 5th, 2022 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /* add this to the flex basis of the loop item
  2. calc((100% / var(--cols)) - (var(--gap) * (var(--cols) - 1)) / var(--cols))
  3. */
  4.  
  5. /* add this to the column gap and row gap of the parent container of the loop item
  6. var(--gap)
  7. */
  8.  
  9. /* set the parent container flex wrap to 'wrap', and direction to 'Horizontal(row)', stretch*/
  10.  
  11.  
  12. /*add this to the custom CSS of parent container of the loop item*/
  13.  
  14.  
  15.  
  16. root {
  17. --gap: 2rem;
  18. --cols: 1; /*mobile*/
  19. }
  20.  
  21.  
  22.  
  23. @media (min-width:581px) {
  24. root {
  25. --cols: 2; /*tablet*/
  26. }
  27. }
  28.  
  29.  
  30. @media (min-width:992px) {
  31. root {
  32. --cols: 3; /*destop*/
  33. }
  34. }
  35.  
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement