Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
DIV variable height using CSS
Old 08-11-2005, 01:17 PM DIV variable height using CSS
TwiztedFake's Avatar
Skilled Talker

Posts: 77
Location: Central, IL
Trades: 0
I'm working on a layout and I am stuck!

My problem is that I can't get a div to stay the same height as the one next to it.


HTML code:

Code:
<div id="main"> 
<div id="leftside"></div>    <------ I want this to be the 100% of the height of "main" 

<br><br><br>Just some test area to play around with<br><br><br>

<div id="rightside"></div>   <------ I want this to be the 100% of the height of "main" 
</div>
CSS code:

Code:
#leftside { 
    width: 14px; 
    background: url(tnav_l.gif); 
    float: left; } 
#rightside { 
    width: 15px; 
    background: url(tnav_r.gif); 
    float: right; } 
#main { 
    width: 100%; 
    text-align: center; 
    background: url(cb_fbr_tex.gif); }

I tried setting height to 100% and of course that doesn't work. I know a quick solution by using tables but I want to keep the entire site css/html validated. Any solutions using CSS?

Complete HTML page: http://www.kmcustoms.com/test/index.html
CSS File: http://www.kmcustoms.com/test/toi.css
__________________

Please login or register to view this content. Registration is FREE
TwiztedFake is offline
Reply With Quote
View Public Profile Visit TwiztedFake's homepage!
 
 
Register now for full access!
Old 08-11-2005, 05:14 PM
danburzo's Avatar
Skilled Talker

Posts: 82
Location: Bistrita RO
Trades: 0
There's no method for stretching the divs. You need to use the faux columns method:http://www.alistapart.com/articles/fauxcolumns/
danburzo is offline
Reply With Quote
View Public Profile
 
Old 08-12-2005, 02:49 AM
TwiztedFake's Avatar
Skilled Talker

Posts: 77
Location: Central, IL
Trades: 0
I went and checked out the link but it won't help in this situation. See I'm not using a fixed width on the layout. It is has a width of 100% and I need that border on both sides of the main div.

If it was fixed width it would have been simple to fix as I have used the method before on a layout. I tried to nest two div's to get the effect that I wanted which led me to another problem when I tried that. I set the first div with the side border to tile vertically and worked fine, just like I wanted. The problem in this case was the border on the right. I tried to set the img as the background on it to tile vertically starting at the top right and neither IE or Netscape displayed it correctly.

So it looks like I might have to use a table to get what I want or change the layout to a fixed width. Other than that I don't see and solution!

edit: I changed it to a fixed width to solve the problem, seems to be the only solution other using a table.
__________________

Please login or register to view this content. Registration is FREE

Last edited by TwiztedFake; 08-12-2005 at 03:13 AM.. Reason: Updated
TwiztedFake is offline
Reply With Quote
View Public Profile Visit TwiztedFake's homepage!
 
Old 08-16-2005, 12:45 PM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
You need to layer your divs.

I normaly set it out like this. Copy it and give it a go.


Code:
 <style>
  #canvas{float:left; width:100%; border:1px dashed black;}
  #header{float:left; width:100%; border:1px dashed black;}
  #left{float:left;width:19%;border:1px dashed black;}
  #content{float:left;width:60%;margin-left:6px;  border:1px dashed black;}
  #right{float:left;width:19%;margin-left:7px; border:1px dashed black;}
  #footer{float:left;width:100%; border:1px dashed black;}
</style>

<div id="canvas">
   <div id="header"> header <br /> <br /><br /> </div>
   <div id="left"> left <br /> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </div>
  <div id="content"> content <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></div>
  <div id="right"> right<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </div>
  <div id="footer"> footer <br /><br /><br /><br /></div>
</div>
I know there is a number of BR's in there but this is to show how the strech works.

The trick is to float everything left, when a box or a series of boxes = 100% it will wrap onto the next line so your left, content and right ID's will all stack next to each other with a header and footer on top and below that. Also make sure you put your widths in % and not px as you will get no stretch.

Best thing about floating is that it displays pretty much the same throughout browsers.

Hope that helps

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf

Last edited by ibbo; 08-16-2005 at 12:48 PM..
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to DIV variable height using CSS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13199 seconds with 12 queries