Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:01:43+00:00 2026-06-10T04:01:43+00:00

I am trying to fill the Frameless grid dynamically (with a Rails loop) and

  • 0

I am trying to fill the Frameless grid dynamically (with a Rails loop) and it is not quite working out..

I understand LESS and the concept of using @1col (@2cols etc..) as variables. But the example that is presented on the site (or rather that is embedded in the site, framelessgrid.com/) shows the use of a large number of hard-coded columns..

Here is the parts of code from framelessgrid.com

LESS file:

@font-size: 17;
@line: 24;
@em: @font-size*1em;

@column: 48;
@gutter: 24;

   @1col:( 1 * (@column + @gutter) - @gutter) / @em;
  @1cols: @1col;
  @2cols:( 2 * (@column + @gutter) - @gutter) / @em;
  @3cols:( 3 * (@column + @gutter) - @gutter) / @em;
  @4cols:( 4 * (@column + @gutter) - @gutter) / @em;
  @5cols:( 5 * (@column + @gutter) - @gutter) / @em;
  @6cols:( 6 * (@column + @gutter) - @gutter) / @em;
  @7cols:( 7 * (@column + @gutter) - @gutter) / @em;
  @8cols:( 8 * (@column + @gutter) - @gutter) / @em;
  @9cols:( 9 * (@column + @gutter) - @gutter) / @em;
@10cols: (10 * (@column + @gutter) - @gutter) / @em;
@11cols: (11 * (@column + @gutter) - @gutter) / @em;
@12cols: (12 * (@column + @gutter) - @gutter) / @em;
@13cols: (13 * (@column + @gutter) - @gutter) / @em;
@14cols: (14 * (@column + @gutter) - @gutter) / @em;
@15cols: (15 * (@column + @gutter) - @gutter) / @em;
@16cols: (16 * (@column + @gutter) - @gutter) / @em;

.width (@cols:1) {
    width: (@cols * (@column + @gutter) - @gutter) / @em;
}
//....


 article section, #colophon {
padding: 0 18/@em;
margin: 0 auto;
max-width: @8cols;
}

#grid {
height: @4cols;
position: relative;
overflow: hidden;
}

.col {
    background: @highlight;
    height: 100%;
    width: @1col;
    position: absolute;
    left: 50%; top: 0;
    margin-left: 12/@em;
}

#grid .col {
    .transition(background-color 0.382s ease-out);
}

    .col2 {margin-left: (1*72+12)/@em;}
    .col3 {margin-left: (2*72+12)/@em;}
    .col4 {margin-left: (3*72+12)/@em;}
    .col5 {margin-left: (4*72+12)/@em;}
    .col6 {margin-left: (5*72+12)/@em;}
    .col7 {margin-left: (6*72+12)/@em;}
    .col8 {margin-left: (7*72+12)/@em;}
    .col9 {margin-left: (8*72+12)/@em;}
    .col10 {margin-left: (9*72+12)/@em;}
    .col11 {margin-left: (10*72+12)/@em;}
    .col12 {margin-left: (11*72+12)/@em;}
    .col13 {margin-left: (12*72+12)/@em;}
    .col14 {margin-left: (13*72+12)/@em;}
    .col15 {margin-left: (14*72+12)/@em;}
    .col16 {margin-left: (15*72+12)/@em;}
    .col17 {margin-left: (16*72+12)/@em;}
    .col18 {margin-left: (17*72+12)/@em;}
    .col19 {margin-left: -(1*72-12)/@em;}
    .col20 {margin-left: -(2*72-12)/@em;}
    .col21 {margin-left: -(3*72-12)/@em;}
    .col22 {margin-left: -(4*72-12)/@em;}
    .col23 {margin-left: -(5*72-12)/@em;}
    .col24 {margin-left: -(6*72-12)/@em;}
    .col25 {margin-left: -(7*72-12)/@em;}
    .col26 {margin-left: -(8*72-12)/@em;}
    .col27 {margin-left: -(9*72-12)/@em;}
    .col28 {margin-left: -(10*72-12)/@em;}
    .col29 {margin-left: -(11*72-12)/@em;}
    .col30 {margin-left: -(12*72-12)/@em;}
    .col31 {margin-left: -(13*72-12)/@em;}
    .col32 {margin-left: -(14*72-12)/@em;}
    .col33 {margin-left: -(15*72-12)/@em;}
    .col34 {margin-left: -(16*72-12)/@em;}
    .col35 {margin-left: -(17*72-12)/@em;}
    .col36 {margin-left: -(18*72-12)/@em;}

    .col1, .col2, .col3, .col4, .col19, .col20, .col21, .col22 {
        background: @emphasis;
    }

HTML file:

<article>


            <figure id="grid">
                <div class="col col1"></div>
                <div class="col col2"></div>
                <div class="col col3"></div>
                <div class="col col4"></div>
                <div class="col col5"></div>
                <div class="col col6"></div>
                <div class="col col7"></div>
                <div class="col col8"></div>
                <div class="col col9"></div>
                <div class="col col10"></div>
                <div class="col col11"></div>
                <div class="col col12"></div>
                <div class="col col13"></div>
                <div class="col col14"></div>
                <div class="col col15"></div>
                <div class="col col16"></div>
                <div class="col col17"></div>
                <div class="col col18"></div>
                <div class="col col19"></div>
                <div class="col col20"></div>
                <div class="col col21"></div>
                <div class="col col22"></div>
                <div class="col col23"></div>
                <div class="col col24"></div>
                <div class="col col25"></div>
                <div class="col col26"></div>
                <div class="col col27"></div>
                <div class="col col28"></div>
                <div class="col col29"></div>
                <div class="col col30"></div>
                <div class="col col31"></div>
                <div class="col col32"></div>
                <div class="col col33"></div>
                <div class="col col34"></div>
                <div class="col col35"></div>
                <div class="col col36"></div>
            </figure>


</article>

So the columns with classes col2 to col18 start showing up in the middle of the screen and go to the right, columns from сcol19 – col36 go from center to the left..

How can I use this concept with a dynamic creation of columns??

I want to do something like:

   <figure id="grid">
  <% My_model.all.each do |m| %>
   <div class="col col1"> <%= m.content %> </div>
  <% end %> 
   </div>

This however will start populating the grid from the middle of the screen (due to CSS in .col):

 .col{left: 50%;}

Of course I can switch to left:0 but it kind of negates the concept of Frameless (pt. 3 in Framelessgrid.com :

  1. Center it in the viewport.
    Align your grid horizontally to the middle of your viewport. For a grid with an even number of columns (pictured), align the center point of your viewport in the middle of the gutter between your two centermost columns. For an odd-numbered grid, align it in the middle of your centermost column.

So how do I stick to this concept but a create / populate columns dynamically from a loop ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:01:44+00:00Added an answer on June 10, 2026 at 4:01 am

    So since this question got a vote..

    Here is how I recreated the grid via Rails erb code (keeping the absolute positioning). I needed a column about 12 columns wide so I just looped to the left and to the right.

    Added to LESS file:

    .contain{
    
        width: @6cols;
        height: @2cols;
        margin-bottom: @gutter/@em;
    }
    

    Controller:

    def index
        @counter = 0
        @ticker =  0
    end 
    

    HTML:

    <figure id="grid">
            <% MyModel.all.each_with_index do |p, i| %>         
        <div class = "contain" >                
                <% @counter = @counter + 2 %>               
                <div class="col col<%= @counter  %>" id ="message_text"> <%= @counter %> || <%= i %> 
    
                </div>
                    <% if @counter == 5  %>
                        <% @counter = 18 %>
                                </div>
                            <div class ="return"></div>
                    <% elsif @counter == 24 %>
                        <% @counter = -1 %> 
                                <% if  @ticker == 0 %>
    
        </div>
        <div class ="return"></div>
                            <% end %>
    
                    <% end %>
            <% @ticker = 1 %>               
            <% end %> 
    </figure>
    

    Here is, however a better (more real-world-like) example, of doing a fixed-width column responsive grid :

    LESS file:

    @column: 85;    // The column-width of your grid in pixels
    @gutter: 20;    // The gutter-width of your grid in pixels
    @half_gutter : @gutter / 2;
    
    @model_fix : 7.5/@em;
    
    
    #build figure {
        height: 100%;
        background: @background;
        position: absolute;
        overflow: none;
        margin: 0 @gutter/@em;
    
    
    }
    
    #build .col {
        float: left;
        left: 0;
            background: white;
    
    }
    
    
    .col {
    
        height: @1col;
        width: @1col;
        position: absolute;
        margin: 0 @half_gutter/@em @gutter/@em @half_gutter/@em;
    
    }
    
    @media screen and (min-width: 78.750em) {
    
    
        .offset {
        left: 50% -  @8cols ; 
    
        }
    
        #build figure {
            height: 100%;
            background: @background;
            position: relative;
            overflow: none;
            margin: 0 auto 0 (@half_gutter - 4)/@em;
            width: @12cols + @gutter/@em;
    
        }
    }
    
    
    .message_text .col {
        width: @2cols;
        height: @2cols - @model_fix*2;
        position: relative;
        color: @grey_text;
    
    }
    
    .message_text #mess_text{
        font-size: 14/@em;
        margin: @half_gutter / @em;
    }
    

    HTML file:

    <body>
    <article>
        <section id="build">                
            <figure id = "models" class ="offset">
                <% @scenes.each_with_index do |s, i | %>
                    <div class ="message_text ">
                        <div class="col">
                            <div id = "model_text" >
    
                    <%= link_to s.title, scene_path(s) %> 
    
    
                            </div>
                            </div>
                    </div>
                <% end %>   
            </figure>
        </section>
    </article>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fill a grid view using data from a db cursor using
I'm trying to fill an array in php with variables, but it's not working
I'm trying to fill my ListView using AsyncTask. Included problem in the comment private
I'm trying to fill-out a form automatically and press a button on that form
I am trying to fill object[] with List<string> but I cannot figure out how
I'm trying to fill devexpress GridControl in background (it's not quick process). I do
I'm trying to fill an array with consecutive integers using Excel and VBA to
I'm new in Ext and I have a problem: I'm trying to fill extjs-grid
I'm trying to fill 100% of the viewport in WebKit (Chrome) using maths .
I am trying to fill the screen with divs, and I'm thinking about using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.