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)

ACI image

ACI.dev: The Only MCP Server Your AI Agents Need

ACI.dev’s open-source tool-use platform and Unified MCP Server turns 600+ functions into two simple MCP tools on one server—search and execute. Comes with multi-tenant auth and natural-language permission scopes. 100% open-source under Apache 2.0.

Star our GitHub!

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay