Note that there are some explanatory texts on larger screens.

plurals
  1. POPositioning Divs semi-randomly, without overlaps
    primarykey
    data
    text
    <p>I have a page which has DIVs which contain short phrases (one-two words) of varying font sizes, which need to be positioned left-to-right according to a numerical parameter, and vertically so as not to overlap.</p> <p>It's like a tag cloud, but there's information contained in the y-axis as well ("coolness" in this case - <a href="http://cool-wall.appspot.com" rel="nofollow noreferrer">http://cool-wall.appspot.com</a>)</p> <p>How should I lay these out? I'm currently using a very messy series of DIVs like this:</p> <pre><code>&lt;div style="position:absolute; top:150px;left:10px;right:10px;bottom:10px"&gt; &lt;!-- then, repeated, with different top, left and font-size values --&gt; &lt;div style="align:center; margin:0; border:none; padding:0; float:left; visibility:visible; position:absolute; top:21%; left:56%; font-size:11px"&gt; &lt;div style="margin-top:0%; margin-right:50%; margin-bottom:0%; margin-left:-50%;"&gt; &lt;a href="foo"&gt;&lt;span style="display:inline"&gt; &amp;larr; &lt;/span&gt;&lt;/a&gt; &lt;a href="bar"&gt;&lt;span style="display:inline"&gt; Buzz &lt;/span&gt;&lt;/a&gt; &lt;span style="display:inline"&gt; &amp;rarr; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- of course, followed by a close div --&gt; &lt;/div&gt; </code></pre> <p>I use a stylesheet to extract some of those styles, and I realise that it's pretty poor CSS (and HTML)... but this was all I could hack together to do (almost) what I wanted to do. The main problem with the above (apart from it being confusing) is that I can't set the positioning so it doesn't overlap, because I don't know what size the font will be, nor how it will display onscreen.</p> <p>Happy to use JavaScript to get it right. But I don't know where to start. Any tips?</p>
    singulars
    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.
    1. This table or related slice is empty.
    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