Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to position children according to where their parents are
    primarykey
    data
    text
    <p>I am making an algorithm builder and have a main text box on top, when I click the "+" underneath it, It adds a copy of itself to the next row. If there's already a row there, it adds it to that row. The problem is I don't want to just add it to the next row, I want it to be position centered under the one that I pressed the "+" symbol. Someone please take a look at my code and give me some suggestion on how i can fix this. Thank you so much.</p> <p>HTML</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Pathway Builder&lt;/title&gt; &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="pathway_builder"&gt; &lt;div class="row" id="row1"&gt; &lt;div class="whole"&gt; &lt;div class="centered_box"&gt; &lt;textarea class="text_field_not_selected"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;input type="button" value="+" class="add_child not_visable" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="jQuery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="selectors.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>javaScript/jQuery</p> <pre><code>$('textarea').live('focusin blur', function() { $(this).toggleClass('text_field_not_selected'); }); $('.whole').live('mouseenter mouseleave', function() { $(this).find('.add_child').toggleClass('not_visable'); }); $(document).ready(function() { $('.add_child').live({ click: function() { var new_row = '&lt;div class="row"&gt;&lt;/div&gt;' var new_child = '&lt;div class="whole"&gt;&lt;div class="centered_box"&gt;&lt;textarea class="text_field_not_selected"&gt;&lt;/textarea&gt;&lt;/div&gt;&lt;input type="button" value="+" class="add_child not_visable" /&gt;&lt;/div&gt;' if ($(this).parents('.row').next().length == 0) { $(this).parents('.row').after(new_row); $(this).parents('.row').next().html(new_child).css('position-x', ''); } else { $(this).parents('.row').next().append(new_child); } } }); }); </code></pre> <p>CSS</p> <pre><code>body { margin: 0px; padding: 0px; text-align: center; } textarea { width: 4em; height: 1em; overflow: hidden; } textarea:focus { outline: none; text-align: center; resize: both; padding-top: 5px; padding-bottom: 5px; } .text_field_not_selected { text-align: center; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; box-shadow: 0px 3px 5px #444; -moz-box-shadow: 0px 3px 5px #444; -webkit-box-shadow: 0px 3px 5px #444; resize: none; } .pathway_builder { text-align: center; } .whole { text-align: center; display: inline-block; background-position-x: 100px; } .centered_box { padding: 10px; padding-bottom: 0px; } .add_child { } .not_visable { visibility: collapse; } .row { } </code></pre>
    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