DEV Community

Cover image for Loop com SCSS para sistema de grid
André Rodrigues
André Rodrigues

Posted on

5 3

Loop com SCSS para sistema de grid

Código em SCSS

.container {
  margin: 0 auto;
  width: 99%;
  @media (min-width: 700px) {
    width: 90%;
  }
}
// Cols
$grid-columns: 12;
[class*="col-"] {
  padding: 0 15px;
}
@media (min-width: 700px) {
  @for $i from 1 through $grid-columns {
    .col-#{$i} {
      width: percentage($i / $grid-columns);
    }
  }
}
// Row
.row {
  display: flex;
  align-items: center;
  flex-direction: column;
  @media (min-width: 700px) {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
Enter fullscreen mode Exit fullscreen mode

Código no HTML

<div class="container">
    <div class="row">
        <div class="col-12">Exemplo de grid</div>
        <div class="col-6">Exemplo de grid</div>
        <div class="col-6">Exemplo de grid</div>
        <div class="col-4">Exemplo de grid</div>
        <div class="col-4">Exemplo de grid</div>
        <div class="col-4">Exemplo de grid</div>
    </div>
</div>

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️