Column Layouthttp://forums.asp.net/t/1795694.aspx/1?Column+LayoutWed, 25 Apr 2012 15:44:47 -040017956944945162http://forums.asp.net/p/1795694/4945162.aspx/1?Column+LayoutColumn Layout <p>I need to make a two column layout (each column will have a border around it and some margin/padding so they don't touch). I've done this with CSS however, the columns are not the same height. I need all columns to be the same height so that it looks professional.</p> <p>I've searched Google and found many solutions, all of which are CSS hacks, or JavaScript, or other 30&#43; lines of code. This should be very simple and I'm SHOCKED to find that Internet Explorer doesn't support this (as I'm told it doesn't). Who would want columns that are all messy?</p> <p>If I wrap the columns in a container div, and set the height to 100% it seems to work, however, I have to float the columns in order to have them side-by-side, and as soon as I float them, they are no longer inline with the rest of the page elements, and are no longer &quot;inside&quot; the container div.</p> <p>I have found many different hack solutions, but I need a professional solution that actually works on all browsers, without having to hack things and cause more problems.</p> <p><a href="http://css-tricks.com/fluid-width-equal-height-columns/">http://css-tricks.com/fluid-width-equal-height-columns/</a></p> <p><a href="http://www.ejeliot.com/blog/61">http://www.ejeliot.com/blog/61</a></p> <p><a href="http://css-tricks.com/super-simple-two-column-layout/">http://css-tricks.com/super-simple-two-column-layout/</a></p> <p><a href="http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm">http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm</a></p> <p>Can someone from here or Microsoft give me the REAL solution, not some hack solution? This is something that is very common in websites, and I'm sure there is support for something so basic by the year 2012. Most of these articles go back to 2006.</p> <p>Thanks!</p> <p>&nbsp;</p> 2012-04-22T23:50:23-04:004945529http://forums.asp.net/p/1795694/4945529.aspx/1?Re+Column+LayoutRe: Column Layout <p>&lt;div id=&quot;outerDiv&quot; width=&quot;100%&quot; height=&quot;700px&quot;&gt;</p> <p>&nbsp; &nbsp;</p> <p>&lt;div id=&quot;leftDiv&quot; width=&quot;200px&quot; height=&quot;100%&quot; style=&quot;float:left;&quot;&gt;</p> <p></p> <p>&lt;/div&gt;</p> <p>&lt;div id=&quot;leftDiv&quot; width=&quot;498px&quot; height=&quot;100%&quot; style=&quot;float:left;&quot;&gt;</p> <p></p> <p>&lt;/div&gt;</p> <p>&lt;/div&gt;</p> <p></p> <p>Also refer this once:</p> <p><a href="http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm">http://matthewjamestaylor.com/blog/equal-height-columns-2-column.htm</a></p> 2012-04-23T06:55:56-04:004947413http://forums.asp.net/p/1795694/4947413.aspx/1?Re+Column+LayoutRe: Column Layout <pre class="prettyprint">I can't get it working like that. The columns always go one top of each other. Also there are two IDs called leftDiv.. I think you can only use an ID once?</pre> &lt;div id=&quot;outerDiv&quot; height=&quot;700px&quot; width=&quot;100%&quot;&gt; &lt;div style=&quot;float: left; background-color: #c0c0c0;&quot; id=&quot;leftDiv&quot; height=&quot;100%&quot; width=&quot;200px&quot;&gt; <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et sapien non lacus lacinia fringilla eu sed lectus. Curabitur ac tincidunt dolor. Aliquam quis nunc eget massa pellentesque sollicitudin. Aliquam mauris enim, vehicula vel blandit id, tincidunt nec nunc. Quisque vulputate, massa ac commodo interdum, lectus dui consectetur risus, in interdum nunc tortor a tortor. Praesent adipiscing volutpat erat placerat feugiat. Duis dapibus tristique metus, at lobortis leo adipiscing eu. Nunc facilisis, sapien quis vestibulum dapibus, mauris justo venenatis ante, ut hendrerit urna tortor vitae lacus. Donec quis viverra justo. Praesent fermentum varius sapien in dapibus. Proin pharetra eros sit amet lorem placerat facilisis egestas tortor sollicitudin. Etiam tempor facilisis elit, cursus hendrerit augue lacinia vel. Vivamus condimentum, tortor at venenatis congue, sem est adipiscing mi, interdum iaculis ante mi eu augue.</p> &lt;/div&gt; &lt;div style=&quot;float: left; background-color: #ff0000;&quot; id=&quot;rightDiv&quot; height=&quot;100%&quot; width=&quot;498px&quot;&gt; <p>Curabitur in est ut nisi euismod convallis. Pellentesque accumsan accumsan velit sit amet eleifend. Aenean vitae nunc vitae erat aliquam posuere sit amet eget sem. Proin suscipit dignissim turpis at tristique. Aliquam fringilla velit non turpis dapibus euismod. Maecenas mi nibh, pellentesque ac mattis nec, molestie vitae elit. Aliquam ac quam non lectus ultrices vestibulum et a mi. Etiam dapibus mauris at orci elementum sodales. Morbi blandit commodo facilisis.</p> &lt;/div&gt; &lt;/div&gt; 2012-04-24T00:42:07-04:004947519http://forums.asp.net/p/1795694/4947519.aspx/1?Re+Column+LayoutRe: Column Layout <p>try this, It will work</p> <p><strong>CSS code:</strong></p> <p>&nbsp;.outerDiv<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height: 500px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: 1px solid blue;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .leftdiv<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 200px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height: 80%;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float: left;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: 1px solid green;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .rightdiv<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 200px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height: 80%;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float: left;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: 1px solid red;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p><strong>HTML Code</strong></p> <p>&lt;div class=&quot;outerDiv&quot;&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&quot;leftdiv&quot;&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am first div<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&quot;rightdiv&quot;&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am second div<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;<br> &nbsp;&nbsp;&nbsp; &lt;/div&gt;</p> 2012-04-24T03:51:56-04:004947594http://forums.asp.net/p/1795694/4947594.aspx/1?Re+Column+LayoutRe: Column Layout <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Kensino</h4> <p></p> <pre class="prettyprint">I can't get it working like that. The columns always go one top of each other. Also there are two IDs called leftDiv.. I think you can only use an ID once?</pre> <p>&nbsp;</p> </blockquote> <p></p> <p>Yea sorry, i forgot to change that, the second inner div can be named as rightDiv.</p> <p>So is it working now?</p> 2012-04-24T04:58:02-04:004949639http://forums.asp.net/p/1795694/4949639.aspx/1?Re+Column+LayoutRe: Column Layout <p>I was able to get the code from res.web working. But the other code example still doesn't work in my browser, even with the right column renamed. It still shows the left column on top of the right column. I'm not sure why.</p> <p>&nbsp;</p> <p>I will just use the other method for now, and get rid of all this hack code I had to put in from before.</p> <p>&nbsp;</p> <p>I don't suppose that this is going to be able to expand vertically is it? Because the height of the outer div is set to 500px. I have no idea how much data will be inside the left and right column, if the content is loaded from the database.</p> 2012-04-25T02:10:38-04:004949669http://forums.asp.net/p/1795694/4949669.aspx/1?Re+Column+LayoutRe: Column Layout <p>Can you tell me why, when I add a padding to your code, to the left column, it makes the left column always longer than the right column. Even if I add the same padding to the right column it doesn't change the right column at all.</p> <p>&nbsp;</p> <p>I want a padding in my column so it looks better, but every time I add it, it messes up the height. I don't understand why that happens.</p> 2012-04-25T02:57:07-04:004949769http://forums.asp.net/p/1795694/4949769.aspx/1?Re+Column+LayoutRe: Column Layout <p>Padding and margin always affects height/width of div.<br> <br> You can apply padding to div as follows:<br> <br> CSS Code<br> &nbsp;.leftdiv<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 200px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height: 80%;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float: left;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: 1px solid green;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; padding:20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .rightdiv<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width: 200px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height:80%;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float: left;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; border: 1px solid red;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; margin: 20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; padding:20px;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> <br> </p> 2012-04-25T04:50:40-04:004949796http://forums.asp.net/p/1795694/4949796.aspx/1?Re+Column+LayoutRe: Column Layout <p>There is no difference between two methods, just that the width and margins of inner divs are different and the one given by res.web uses External CSS files and mine uses inline CSS.</p> 2012-04-25T05:18:36-04:004951218http://forums.asp.net/p/1795694/4951218.aspx/1?Re+Column+LayoutRe: Column Layout <p>So is there any way to make this expand vertically when content is added from the database? What will happen if the content is too long for the container div? I think I need to use a 100% height on the container div as well, but that doesn't seem to work.</p> <p>&nbsp;</p> <p>Also, can you explain <em>why</em> padding changes the height or width of a div? If all I'm trying to do is move the text it contains down or in a little, I don't see how that affects the div, just by moving the placement of the text or other content inside it.</p> 2012-04-25T15:44:47-04:00