Giter Club home page Giter Club logo

silc-grid's People

Contributors

nickrigby avatar

Watchers

 avatar  avatar  avatar

Forkers

anthonybarsotti

silc-grid's Issues

Collapsing margins for child elements of `.silc-grid__col`'s

Since flexbox doesn't support collapsing margins, sometimes using silc-grid causes there to be excess whitespace. For example, if paragraphs have margin-bottom: 20px and heading tags have margin-top: 30px, normally a paragraph followed by a heading would have 30px of space beneath it. If a silc-grid with a paragraph inside one of its silc-grid__col's comes before a heading though the spacing will be 50px because margins don't collapse with flex containers. I've come up with the following Sass to address this:

.silc-grid--collapse-children .#{$silc-grid--namespace}grid__col {
  @each $breakpoint-name, $breakpoint-width in $silc-core--breakpoints {
    @for $x from 1 to $silc-grid--columns + 1 {
      &--#{$x}-#{$breakpoint-name} {
        &:first-child > *:first-child {
          margin-top: 0;
        }
        &:last-child > *:last-child {
          margin-bottom: 0;
        }
        @include media(#{$breakpoint-name}) {
          > *:first-child {
            margin-top: 0;
          }
          > *:last-child {
            margin-bottom: 0;
          }
        }
      }
    }
  }
}

This forces the first column's first child to always have no margin-top and the last column's last child to have no margin-bottom. When columns aren't stacked it applies those styles to the first and last children of each column. Proposing that this functionality will be available via a modifier class like .silc-grid--collapse-children.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.