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 7755835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:39:50+00:00 2026-06-01T12:39:50+00:00

I am implementing a jquery file upload page. While a user is adding files,

  • 0

I am implementing a jquery file upload page. While a user is adding files, I want them to be getting listed in a form of an icons in an auto-sizable grid.

Auto-sizable means it provides maximum space for containing elements. When there is two objects – it woud look like (I know i will have to handle image resizing myself):

two items js grid

When several are added:

several items js grid

Is there a “grid control” (jquery perhaps) that does at least close to what I need sizing wise?

  • 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-01T12:39:51+00:00Added an answer on June 1, 2026 at 12:39 pm

    First of all, please keep in mind that I’m a jQuery newbie and this is my first post on Stackoverflow 🙂

    I’ve the same problem and I’ve try to fix it using jQuery and CSS. This is my body tag content:

    <div id="controls">
    Controls:
        <button id="add">+</button>
        <button id="del">-</button>
    Current ratio:
        <span id="value"></span>
        <button id="increase">+</button>
        <button id="decrease">-</button>
    Referred to:
        <form style="display: inline;">
            width<input type="radio" name="maximize" value="width">
            height<input type="radio" name="maximize" value="height">
        </form>
    </div>
    <div id="elements" style="width: 500px; height: 300px; background: black;">
    </div>
    <script>
    ratio      = 1;
    ratioWidth = true;
    function autoresize() {
        boxes   = $('#elements').children().size(); 
        rows    = Math.ceil(Math.sqrt(boxes/ratio));
        columns = Math.ceil(boxes/rows);
        if (!ratioWidth) {
            tmp     = rows;
            rows    = columns;
            columns = tmp;
        }
        $('#elements').children().css('width',  100/rows+'%');
        $('#elements').children().css('height', 100/columns+'%');
    }
    function add() {
        red   = Math.floor(Math.random()*256);
        green = Math.floor(Math.random()*256);
        blue  = Math.floor(Math.random()*256);
        color = 'rgb('+red+','+green+','+blue+')';
        $('#elements').append("<div style=\"background: "+color+"; float: left;\"></div>");
        autoresize();
    }
    function update() {
        $('#value').text(ratio);
        autoresize();
    }
    function remove() {
        $('#elements').children().last().remove();
        update();
    }
    function increase() {
        ratio++;
        update();
    }
    function decrease() {
        if (ratio > 1) {
            ratio--;
            update();
        }
    }
    $(document).ready(function() {
        $('#add').click(add);
        $('#del').click(remove);
        $('#increase').click(increase);
        $('#decrease').click(decrease);
        if (ratioWidth) value = 'width'
        else value = 'height'
        $('input[type=radio]').filter('[value='+value+']').attr('checked', true);
        $('input[type=radio]').live('change', function() {
            if ($(this).val() == 'width') ratioWidth = true
            else ratioWidth = false;
            autoresize();
        });
        update();
        //$(window).bind("resize", autoresize);
    });
    </script>
    

    You could remove the background color stuff and put your icons centered in those boxes.
    If you find a better way of if you improve this code, please let me know 🙂

    Edit 1 – I’ve added some Math.floor(...) to remove a bug when boxes side has repeating decilmals: very size is a simple integer. Now dimensions are fetched from the container div, I use black as background color for the main container and I’ve noticed a little issue: sometimes I see a black border near the little boxes, even if I don’t set any background color. Could it be a Firefox rendering glitch?

    Edit 2 – Now it’s possible to set if you prefer to auto-expand horizontally, vertically, or none of them. I’ve tried to write a better code, and I’ve commented autoresize when the window is resized (use it only if your container box hasn’t a fixed height/width). I think that now it needs an ratio option, in order to specify if width have to be twice longer for example. Live example: http://experimental.frafra.eu/maxarea2.html

    Edit 3 – New code! Better graphical representation and a new parameter: ratio. Ratio is a coefficient between the ratio between main container width/height and the elements one. Live example: http://experimental.frafra.eu/maxarea3.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a jquery autocomplete on a search form and am getting the
I'm implementing jQuery File Upload and trying to figure out the best way to
I am implementing jQuery tabs on mysite, one of the tabs holds a form
So I'm implementing a the Jquery UI slider on my page. The value of
I'm having trouble implementing this jQuery plugin for dynamic forms while following this tutorial
I am implementing a portlet/widget JQuery interface using Interface and JQuery. The user drags
I'm implementing a vote system and I want to use jQuery. I have the
today I was implementing jQuery Progress-bars on a web-page. I needed to implement about
I am finally getting around to really implementing some jQuery solutions for my apps
I am implementing Location field in JS form using JSON,JQUERY state <select name=state id=state-list

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.