Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to make a table-looking structure using non-table markup?
    primarykey
    data
    text
    <p>I'm trying to build a simple table using <code>box-sizing:border-box;float:left</code> elements.</p> <p>Warning 1. Maybe my approach is bad, even maybe there's no need to use "float" and "box-sizing" properties to complete this task, then what would you do in this situation? Warning 2. Of course, you should remember that you must use a modern CSS3-capable browser to view this markup :)</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;style&gt; div { vertical-align:top; margin:0px; padding:0px; } div.table { border:solid 2px green; width:90%; background-color:red; } div.table &gt; div:not(.clear) { -moz-box-sizing:border-box; box-sizing:border-box; float:left; max-height:8em; overflow:auto; border:solid thin black; background-color:white; } div.table &gt; div:nth-child(3n+1):not(.clear) { clear:left; width:40%; } div.table &gt; div:nth-child(3n+2):not(.clear),div.table &gt; div:nth-child(3n+3):not(.clear) {width:30%;} div.clear {clear:both;height:0px;border-style:none;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="table"&gt; &lt;div&gt; Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first &lt;/div&gt; &lt;div&gt;Middle first&lt;/div&gt; &lt;div&gt;Right first&lt;/div&gt; &lt;div&gt;Left second&lt;/div&gt; &lt;div&gt;Middle second&lt;/div&gt; &lt;div&gt;Right second&lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>You see that red zone, it's showing that "Middle first" and "Right first" divs heights don't stretch to fit the element with the greatest height in the row. How to force them to automatically stretch its heights? I would prefer a pure CSS solution, but accept javascript (jquery) solution if it can deal with very, very large tables...</p> <p><strong>EDIT:</strong> Of course, using the floating elements is not an approach for my task, forget it. I don't like the implementation, but this may give a better understanding of what I want:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;style&gt; div {vertical-align:top;margin:0px;padding:0px;} div.table {display:inline-block;border:solid 2px green;background-color:red;} div.table &gt; div{display:inline-block; max-height:8em;overflow:auto; border:solid thin black;background-color:white;} &lt;/style&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function () { $('&lt;br /&gt;').insertAfter($("div.table &gt; div:nth-child(3n+3)").not(':last')); $("div.table &gt; div:nth-child(4n+1)").each(function () { $(this).css('width', '15em'); if ($(this).height() &lt; $(this).next('div').height() || $(this).height() &lt; $(this).next('div').next('div').height()) { $(this).height(Math.max($(this).next('div').height(), $(this).next('div').next('div').height())); } }); $("div.table &gt; div:nth-child(4n+2)").each(function () { $(this).css('width', '10em'); if ($(this).height() &lt; $(this).prev('div').height() || $(this).height() &lt; $(this).next('div').height()) { $(this).height(Math.max($(this).prev('div').height(), $(this).next('div').height())); } }); $("div.table &gt; div:nth-child(4n+3)").each(function () { $(this).css('width', '10em'); if ($(this).height() &lt; $(this).prev('div').height() || $(this).height() &lt; $(this).prev('div').prev('div').height()) { $(this).height(Math.max($(this).prev('div').height(), $(this).prev('div').prev('div').height())); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="table"&gt; &lt;div&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;br /&gt;Left first&lt;/div&gt;&lt;div&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;Middle first&lt;br /&gt;longlonglonglonglonglonglonglonglonglong&lt;/div&gt;&lt;div&gt;Right first&lt;/div&gt; &lt;div&gt;Left second&lt;/div&gt;&lt;div&gt;Middle second Middle second Middle second&lt;br /&gt;longlonglonglonglonglonglonglonglonglong&lt;/div&gt;&lt;div&gt;Right second&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Disadvantages: 1. Requires a bunch of ugly JS. 2. There are red zones which appear when scrollbars are present, or when you zoom the page. They differ in different browsers. Does anybody know where do they come from??? Is it possible to get rid of them? If no, I'll try to make use of something like equalHeights jquery plugin<br> <strong>EDIT 2:</strong><br> I found a script equalizing heights of all the elements in a row, but I won't use it because now I realize that there is no script that may be applied to large table-like structure. CSS Flexible Box Layout Module is a solution, but it's currently not supported by the major browsers, and is being rendered much slower than normal tables.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload