Answer the question
In order to leave comments, you need to log in
Is it better to create a set of CSS classes for the grid or style each block of the site separately?
I'm used to working with CSS frameworks, but now I need to do a couple of projects without them.
As always, a column grid is needed in some places.
There are two options:
1. Do the same as done in frameworks - create (or download a ready-made) set of common grid classes. Everything is standard - .row .columns etc.
Then use them throughout the project, layout as with a framework:
<div class="row">
<div class="column large-12">
<div class="top">
content
</div>
</div>
</div>
<div class="row">
<div class="column large-6">
<div class="some-section">
some content
</div>
</div>
<div class="column large-6">
<div class="information">
some content
</div>
</div>
</div>
<div class="top">
Some content
</div>
<div class="block">
<section class="block__element">
some content
</section>
<section class="block__element">
some content
</section>
</div>
Answer the question
In order to leave comments, you need to log in
There is no single answer, both options are possible depending on the situation.
Practice shows that the first option is more often suitable for sites that are assembled from many bricks as a constructor and there are a lot of combinations of these bricks (for example, admin panels).
For sites with a more or less unique design, the second approach is often better, because well, there are no complex designs that could be completely described by 12 equal columns. Although under the hood there are still usually some elements of the first approach, only in the form of mixins.
I like this tool here:
https://m.youtube.com/playlist?list=PLyeqauxei6je2...
For the global grid (the relative position of large top-level blocks), you can create your own .container block , which will be the centerer, and mix it in the markup or make it a wrapper block (when there is a 100% background):
<div class="features container">
Some content
</div>
<div class="features">
<div class="container">
<section class="features__element">
some content
</section>
<section class="features__element">
some content
</section>
</div>
</div>
// Каскад от Мобильных к Десктопам
.container {
width: 280px;
padding: 0 20px;
}
@media (min-width: 768px) {
.container {
width: 640px;
padding: 0 60px;
}
}
@media (min-width: 1200px) {
.container {
width: 960px;
padding: 0 100px;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question