![]() |
DIV side by side
I'm finding myself use negative numbers for my 2nd DIV if I need it to be set next to another DIV. I'm currently using relative positions.
Is there a way to put DIVs next to each other without making a cluster code? |
.divclass { width:200px; float:left; display:block; }
then after all the divs you will need one more div with <div style="clear:both"></div> that should work. |
works like a charm :)
|
hm this wont work if i need more DIVs under each other. they tend to sorta spaz out
|
Set a height then. That will fix it you also might want to add overflow:hidden;
so the css will be .divclass { width:200px; float:left; display:block; height:20px; overflow:hidden; } |
hm that didnt do anything. What I'm looking for is something like this:
Header1--------------------Header2 Content1-------------------Content2 The problem though, with your code, whats happening in the following: Header1 Content1-----------Header2 -----------------------Content2 I already added the overflow and height but nothing :/ EDIT: I just added the overflow to content1 and content2 with a set height and it fixed content2 to be right under header2 but content1 is still not positioned where it suppose to be. It should be under header1 but its right on the top margin, and right next to header1. So this is what it looks like now: Header1 Content1------------Header2 -----------------------------------Content2 |
Can you post your actual code for me.
|
Sure
Code:
body {hm I'm wondering, maybe, its not working because I dont have wrappers for the actual content. Maybe it will work if I wrap navleft and navright together and contentleft and contentright together? that way it doesn't conflict with any other DIVs but the ones inside the wrapper? |
HTML Code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
The problem is not a really a css or an html problem but a problem with the sizes you picked.
.navleft { width:100px; float:left; display:block; height:50px; overflow:hidden; } .navright { width:150px; float:right; display:block; height:50px; overflow:hidden; } .contentleft { top:0; margin:0; width:500px; float:left; display:block; background:#FFF; color: #000; overflow: hidden; height:100px; } .contentright { top:0; left:0; margin:0; width:141px; float:right; display:block; color:#FFF; overflow:hidden; height:400px; } change that to .navleft { width:500px; float:left; display:block; height:50px; overflow:hidden; } .navright { width:150px; float:right; display:block; height:50px; overflow:hidden; } .contentleft { top:0; margin:0; width:500px; float:left; display:block; background:#FFF; color: #000; overflow: hidden; height:500px; } .contentright { top:0; left:0; margin:0; width:150px; float:right; display:block; color:#FFF; overflow:hidden; height:400px; } that should clean it up. You basically just had your wrapper to large and your contents to small. |
yyesss it worked. thanks, i didnt catch that earlier
|
Cory,
I have a new CSS problem. Remember how we set the tables to be all the same height? Well now the tables are going to change a little. They need to stack under each other with a padding of about 10-20 pixels. The problem is, when I use your code, the heights on all of them are the same, thus creating a huge gap in between the tables. It's going to be 3 tables in one row, and 3 tables in the second row. With different heights on each table. In essence they wont be straightly aligned, some will be higher than others. Or would I just have to force the tables to move the way I want them to? I hope you understand me. |
This would be much easier if you posted a link, so we could see what is going on.
If you set the height of a class of div and then put each table in its own div that might help you, but without a site to play with and edit, it's tricky to see what your problem is. PS you have some totally unnecessary code there, where you tell a div to use display:block; because a div is a block level element by definition. |
| All times are GMT. The time now is 10:53 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0