Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery when using dynamically created child divs - float: left loses the child divs
    primarykey
    data
    text
    <p>Hi I've tried a number of different methods to try and work this problem but I'd like your help please.</p> <p>I have a a css formatted but empty SECTION that I'm trying to dynamically create a layout within using JQuery when a button is clicked.</p> <p>This is my html section:</p> <pre><code>&lt;SECTION ID="Section_Article_1"&gt; &lt;P CLASS="header"&gt;Title&lt;/P&gt; &lt;/SECTION&gt; </code></pre> <p>This is my script:</p> <pre><code>$(document).ready(function(){ $("#btn1").click(function(){ var topStyles = { backgroundColor : "#69830E", color: "#ffffff", fontSize: 20, fontWeight: "", textAlign: "center", marginTop: "-20px", }; $("#Section_Article_1").append("&lt;div id = 'title'&gt;&lt;p&gt;Header&lt;/p&gt;&lt;/div&gt;"); $("#title").css(topStyles); var leftColumn = { backgroundColor : "#ffffff", width: "30%", height: "500px", color: "#000000", fontSize: 18, fontWeight: "", marginTop: "-20px", float:left, paddingLeft: "2px", }; $("#Section_Article_1").append("&lt;div id = 'left'&gt;&lt;p&gt;Left Column&lt;/p&gt;&lt;/div&gt;"); $("#left").css(leftColumn); var rightSection = { backgroundColor : "#000000", width: "70%", height: "500px", color: "#ffffff", fontSize: 18, fontWeight: "", textAlign: "center", marginTop: "-18px" }; $("#Section_Article_1").append("&lt;div id = 'right'&gt;&lt;p&gt;Right Section&lt;/p&gt;&lt;/div&gt;"); $("#right").css(rightSection); }); }); </code></pre> <p>When I run the function my "title" div appears fine as I want it, but the other two are not there. When I remove the "float: left" from my second div, they both appear but are displayed one on top of the other.</p> <p>I'm trying to get my title bar to display across the top, then my other two to be beneath it with my second div "left" to display on the left and the third div "right" to display on the right next to "left"</p> <p>I tried setting my containing section to display:inline but it didn't work either.</p> <p>How can I display my "left" div and "right" div inline without them disappearing? Thanks</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.
 

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