in Education by
I'd like to line up items approximately like this: item1 item2 i3 longitemname i4 longitemname2 anotheritem i5 Basically items of varying length arranged in a table like structure. The tricky part is the container for these can vary in size and I'd like to fit as many as I can in each row - in other words, I won't know beforehand how many items fit in a line, and if the page is resized the items should re-flow themselves to accommodate. E.g. initially 10 items could fit on each line, but on resize it could be reduced to 5. I don't think I can use an html table since I don't know the number of columns (since I don't know how many will fit on a line). I can use css to float them, but since they're of varying size they won't line up. So far the only thing I can think of is to use javascript to get the size of largest item, set the size of all items to that size, and float everything left. Any better suggestions? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This can be done using floated div's, calculating the max width, and setting all widths to the max. Here's jquery code to do it: html:
something
something else
css: div.item { float: left; } jquery: var max_width=0; $('div.item').each( function() { if ($(this).width() > max_width) { max_width=$(this).width(); } } ).width(max_width); Not too ugly but not too pretty either, I'm still open to better suggestions...

Related questions

0 votes
    I'd like to line up items approximately like this: item1 item2 i3 longitemname i4 longitemname2 anotheritem ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'd like to line up items approximately like this: item1 item2 i3 longitemname i4 longitemname2 anotheritem ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I'd like to line up items approximately like this: item1 item2 i3 longitemname i4 longitemname2 anotheritem ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I want to have a tree expanded only when it is required. eg: OS Type is a leaf node it does not expand, but Memory has ... p.groupingView.sortnames[0], l = names.length; for (i=0;i...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I have a div and, inside it, an unordered list with several list items that serve as navigation menu ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am newbie to android development and learning it to my own. I have a very strange problem of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I am newbie to android development and learning it to my own. I have a very strange problem of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    What is the initial step to set up a CSS Lazy Loading? (a) Fetching data (b) Loading the script ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    9)Disk space is a computer maintenance utility included in Microsoft windows designed to free up disk space on a ... true or false Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    A coin is tossed repeatedly until a tail comes up for the first time. Write the sample space for this experiment. Select the correct answer from above options...
asked Nov 22, 2021 in Education by JackTerrance
0 votes
    If the retention policy is set to two days, then for the two days after a record is published, it is available for ... will be discarded to free up space. (1)True (2)False...
asked Jun 17, 2021 in Technology by JackTerrance
0 votes
    Which of the following design approaches help in building sites that are optimized for varied screen sizes ... Adaptive Web Design Progressive Enhancement Mobile Optimized Design...
asked Sep 5, 2021 in Technology by JackTerrance
0 votes
    Which of the following design approaches help in building sites that are optimized for varied screen sizes? (1) ... Web Design (3)Progressive Enhancement (4)Responsive Web Design...
asked Jun 1, 2021 by JackTerrance
0 votes
    Mother, father and son line up at random for a family picture E : son on one end, F : father in middle Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    Write the HTML code to get the line with 5 as thickness, length 50% and color as red Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
...