Note that there are some explanatory texts on larger screens.

plurals
  1. POElement created with a JS loop overlaps another element
    primarykey
    data
    text
    <p>I'm trying to place images from a <code>div</code> to a <code>span</code>. The result is that the images overlap and I don't know how to position each image as it is added. </p> <p>This is my code: </p> <p>The CSS</p> <pre><code>&lt;style type="text/css"&gt; body{background-image:url('image/wood.jpg');} h1, h3, h4, h5, h6, p{text-align:center; font-family:helvetica; font-weight:900;} h3, h4, h5 {color:red;} h1, h6, p{color:white;} img{height:120px;} span{display:inline-block; margin-left: 25px; height:250px;} div.inv{background-image:url('image/shelf.jpg'); background-position:fixed; background-repeat:none;} span#la, span#me, span#sm{margin-left:auto; margin-right:auto; width:800px;} div{background-image:url('image/crate.jpg'); margin-left:25px; margin-right:25px;} </code></pre> <h2> </h2> <p>The Javascript</p> <pre><code>var temp = null; var largeArray = new Array(6); function isTemp() { if(temp == null) { alert("Please pick an item to place in the container"); } } function fillLarge() { isTemp(); if(largeArray[0] != undefined &amp;&amp;largeArray[1] != undefined &amp;&amp;largeArray[2] != undefined &amp;&amp; largeArray[3] != undefined &amp;&amp;largeArray[4] != undefined &amp;&amp;largeArray[5] != undefined) { alert('This crate is full'); } else { for (var i=0; i&lt;6; i++) { if (largeArray[i] == undefined) { largeArray[i] = "&lt;img src='image/"+temp+".jpg'/&gt;"; document.getElementById("la").innerHTML = largeArray[i]; break; } } document.getElementById(temp).style.display="none"; temp = null; } } </code></pre> <hr> <p>the HTML</p> <pre><code>&lt;div&gt; &lt;h3&gt; LARGE CONTAINER &lt;/h3&gt; &lt;span id="la" onclick="fillLarge();"&gt; &lt;/span&gt; &lt;/div&gt; &lt;span id = "gold" onclick = "temp = this.id;"&gt; &lt;img src="image/gold.jpg"/&gt; &lt;p&gt; Gold that you didn't farm &lt;/p&gt; &lt;/span&gt; &lt;span id = "Moarg" onclick = "temp = this.id;"&gt; &lt;img src="image/Moarg.jpg" /&gt; &lt;p&gt; Mo'arg Slave for &lt;br /&gt; your engineering needs &lt;/p&gt; &lt;/span&gt; &lt;span id = "sweetroll" onclick = "temp = this.id;"&gt; &lt;img src="image/sweetroll.jpg" /&gt; &lt;p&gt; Sweetroll stolen from a citizen &lt;/p&gt; &lt;/span&gt; &lt;span id = "uranium" onclick = "temp = this.id;"&gt; &lt;img src="image/uranium.jpg" /&gt; &lt;p&gt; Uranium Ore &lt;/p&gt; &lt;/span&gt; </code></pre> <p>I don't know how to use jQuery, or anything pass the basic javascript.</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.
 

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