Skip to content

Instantly share code, notes, and snippets.

@johnsfuller
Last active May 11, 2022 15:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsfuller/967809f3304e0b83e6406e6c432814b2 to your computer and use it in GitHub Desktop.
Save johnsfuller/967809f3304e0b83e6406e6c432814b2 to your computer and use it in GitHub Desktop.
A modern, mobile-first approach to HubSpot's layout.css file
/* required css vars
* --site-width (site max-width)
* --site-gutter (site container padding)
* --site-spacing-y (site vertical rhythm)
* --hs-grid-gap-x (horizontal gap between dnd columns)
*/
.dnd-section {
padding: 4em 0;
}
/* row-module class for full row modules that utilize the --site-gutter var */
.dnd-section .row-module {
margin: 0 calc(var(--site-gutter) * -1);
}
.dnd-section > .row-fluid {
margin-left: auto;
margin-right: auto;
max-width: var(--site-width);
padding-left: var(--site-gutter);
padding-right: var(--site-gutter);
position: relative;
}
.dnd-section > .row-fluid .hs-private {
width: 100%; /* for the dnd add module here placeholder */
}
@media (min-width: 768px) {
.dnd-section .row-fluid {
column-gap: var(--hs-grid-gap-x);
display: flex;
}
.dnd-section [class*='span'] {
flex: 1;
}
{% for i in range(0,13) %}
.dnd-section .span{{ i }} {
flex-basis: {{ i / 12 * 100 ~ '%' }};
}
{% endfor %}
}
/* page editor */
.hs-inline-edit .dnd-module {
min-height: 40px!important;
}
@johnsfuller
Copy link
Author

Got any thoughts or questions? Comment below 👇 and/or follow me on Twitter @johnIsFuller

@johnsfuller
Copy link
Author

Heads up if any of you use this... the visibility classes (.hide, .show, etc) are not included!

@adesignl
Copy link

adesignl commented May 9, 2022

i would use the gap instead of column-gap .. https://caniuse.com/?search=gap

@johnsfuller
Copy link
Author

Yeah I definitely thought about it – but since gap is shorthand for row-gap & column-gap and the hs dnd grid does not wrap (making row-gap useless), I just included column-gap @adesignl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment