MacTalk Forums

Go Back   MacTalk Forums > Using Your Computer > Help and New Mac User Support

Notices

Help and New Mac User Support There's no such thing as a stupid question here.
Flame free zone.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 31st May 2009, 05:07 PM
Meh 626's Avatar
Need to wake up some time
 
Join Date: Nov 2007
Location: Melbourne
Posts: 791
Send a message via MSN to Meh 626 Send a message via Skype™ to Meh 626
Default CSS Help: DIV Stretch to fit Contents

Hi,

I have searched and searched regarding this topic and tried many things with no luck. I am out of ideas. I need your help MacTalk.

I am creating a site, I have a <div> with two <span>'s in it, one containing the main content. I would like the <div> to stretch to fit all of the content, so far I have not been able to get this to work.

Here is a snippet of the HTML code:
Code:
<div id="contenttop" align="center"></div>
</center>
<center>
<div id="contentbody" align="center">
<br />
<span id="titlefont">Test</span>
<br /><br /><br />
<!-- Editable Content-->
<span id="contentfont"><!--#include virtual="include/About.txt" --></span>
<!-- End Editable Content-->
<br /><br />
</div>
</center>
<center>
<div id="contentbottombar" align="center"></div>
</center>
You can view the result here: Meh626 DIV Stretching Help!

Here is a snippet of the CSS code:
Code:
#contentbody {
	width: 700px;
	z-index: 2;
	margin-left: auto;
	margin-right: auto;
	background-color: #CCCCCC;
	border-right-width: 1px;
	border-left-width: 1px;
	border-right-style: solid;
	border-left-style: solid;
	border-right-color: #999999;
	border-left-color: #999999;
}
#contenttop {
	width: 702px;
	height: 11px;
	background-image: url(../images/contenttop.png);
	background-repeat: repeat-x;
	background-position: top;
	z-index: 3;
	margin-left: auto;
	margin-right: auto;
}
#contentbottombar {
	width: 700px;
	height: 12px;
	background-image: url(../themes/balloons/cloudbar.png);
	background-repeat: repeat-x;
	background-position: bottom;
	z-index: 4;
	border: 1px solid #999999;
	margin-left: auto;
	margin-right: auto;
	clear: both;
}
#contentfont {
	font-family: Arial;
	font-size: small;
	color: #444444;
	text-align: left;
	margin-left: 20px;
	margin-right: 20px;
	width: 660px;
	height:auto;
	float: left;
	z-index: 2;
}
#titlefont {
	font-family: Arial;
	font-size: x-large;
	color: #B40138;
	text-align: left;
	float: left;
	margin-left: 20px;
	text-shadow: rgba(0,0,0,0.5)1px 1px 0px;
	font-weight: bold;
	line-height: 200%;
	width: 700px;
}
You can view the full CSS here: http://meh626.com/help/css/sitestylestest.css

Any help would be greatly appreciated.

Thank you,

__________________
Meh 626 & Meh626.com
 iMac G4 800Mhz PowerPC, 17", Mac OS X Tiger  iPhone 3GS 16GB Black Optus
Successful Trades: Huy, darksplat, The Architect.mac, Beau and Jordan M.
Reply With Quote
  #2 (permalink)  
Old 31st May 2009, 06:09 PM
iMac600's Avatar
Needs a Snappy User Title
 
Join Date: Jun 2006
Location: Adelaide, South Australia
Posts: 439
Send a message via AIM to iMac600 Send a message via MSN to iMac600 Send a message via Skype™ to iMac600
Default

I'm not sure this is the best fix, but it should accomplish what you're after anyway.

In the HTML file, change this portion:

Code:
</span>
<!-- End Editable Content-->
<br /><br />
</div>
To:

Code:
</span>
<!-- End Editable Content-->
<br /><br />
<div style="clear:both;"></div>
</div>
Basically adding <div style="clear:both;"></div> below the two <br /> tags.

Here's the same page with that change applied (hosted off my temp server):

Meh626 DIV Stretching Help!
__________________
iMac Core 2 Duo/1.83GHz
PowerBook G4 Titanium/867MHz
iPhone 3G 8GB

Last edited by iMac600; 31st May 2009 at 06:15 PM.
Reply With Quote
  #3 (permalink)  
Old 31st May 2009, 06:17 PM
Meh 626's Avatar
Need to wake up some time
 
Join Date: Nov 2007
Location: Melbourne
Posts: 791
Send a message via MSN to Meh 626 Send a message via Skype™ to Meh 626
Default

Quote:
Originally Posted by iMac600 View Post
I'm not sure this is the best fix, but it should accomplish what you're after anyway.

In the HTML file, change this portion:

Code:
</span>
<!-- End Editable Content-->
<br /><br />
</div>
To:

Code:
</span>
<!-- End Editable Content-->
<br /><br />
<div style="clear:both;"></div>
</div>
Basically adding <div style="clear:both;"></div> below the two <br /> tags.
Awesome, it worked. Thanks so much! But another issue has turned up, when you shrink the window so the balloons go behind the content area, the text drops. Any ideas?
__________________
Meh 626 & Meh626.com
 iMac G4 800Mhz PowerPC, 17", Mac OS X Tiger  iPhone 3GS 16GB Black Optus
Successful Trades: Huy, darksplat, The Architect.mac, Beau and Jordan M.
Reply With Quote
  #4 (permalink)  
Old 31st May 2009, 07:57 PM
<subject name here>
 
Join Date: Apr 2009
Location: <subject hometown here>
Posts: 108
Send a message via AIM to saphylia
Default

Quote:
Originally Posted by Meh 626 View Post
<snip> ..when you shrink the window so the balloons go behind the content area, the text drops. Any ideas?
I can't replicate that in any way, for me the text is always lower than it should be if it was indeed meant to sit at the top of the window.

At any rate, those balloons scare me, you might want to fix the magic wand job on the sides of them.
Reply With Quote
  #5 (permalink)  
Old 31st May 2009, 08:52 PM
marc's Avatar
Moderator
 
Join Date: Apr 2005
Posts: 6,042
Default

Worth looking at if you want to create bulletproof, complex CSS layouts quickly: Blueprint: A CSS Framework | Spend your time innovating, not replicating
__________________
iStat for iPhone!
Over 12 million widgets and apps downloaded: iSlayer.com (RSS), iPhone apps: Bjango.com (RSS, Twitter)
Record TV easily: IceTV (RSS, IceTV iPhone app, Twitter)
Reply With Quote
  #6 (permalink)  
Old 31st May 2009, 09:13 PM
iMac600's Avatar
Needs a Snappy User Title
 
Join Date: Jun 2006
Location: Adelaide, South Australia
Posts: 439
Send a message via AIM to iMac600 Send a message via MSN to iMac600 Send a message via Skype™ to iMac600
Default

Quote:
Originally Posted by Meh 626 View Post
Awesome, it worked. Thanks so much! But another issue has turned up, when you shrink the window so the balloons go behind the content area, the text drops. Any ideas?
In css/sitestylesheet.css, Line 343 (within #themeright), replace:

Code:
position: relative;
With:

Code:
position:absolute; right:0;
That should correct the issue. I've updated the test version with these changes so you can see for yourself. Meh626 DIV Stretching Help!
__________________
iMac Core 2 Duo/1.83GHz
PowerBook G4 Titanium/867MHz
iPhone 3G 8GB
Reply With Quote
  #7 (permalink)  
Old 31st May 2009, 09:17 PM
<subject name here>
 
Join Date: Apr 2009
Location: <subject hometown here>
Posts: 108
Send a message via AIM to saphylia
Default

Quote:
Originally Posted by marc View Post
Worth looking at if you want to create bulletproof, complex CSS layouts quickly: Blueprint: A CSS Framework | Spend your time innovating, not replicating
Personally I prefer, and use the 960 system, see 960 Grid System.
Reply With Quote
  #8 (permalink)  
Old 31st May 2009, 10:02 PM
Meh 626's Avatar
Need to wake up some time
 
Join Date: Nov 2007
Location: Melbourne
Posts: 791
Send a message via MSN to Meh 626 Send a message via Skype™ to Meh 626
Default

Quote:
Originally Posted by iMac600 View Post
In css/sitestylesheet.css, Line 343 (within #themeright), replace:

Code:
position: relative;
With:

Code:
position:absolute; right:0;
That should correct the issue. I've updated the test version with these changes so you can see for yourself. Meh626 DIV Stretching Help!
Thanks mate! Works great.

Quote:
Originally Posted by saphylia View Post
At any rate, those balloons scare me, you might want to fix the magic wand job on the sides of them.
Fixed the balloons, thanks for the tip. I have taken down the test site since the issue has been solved.

Thanks all.
__________________
Meh 626 & Meh626.com
 iMac G4 800Mhz PowerPC, 17", Mac OS X Tiger  iPhone 3GS 16GB Black Optus
Successful Trades: Huy, darksplat, The Architect.mac, Beau and Jordan M.
Reply With Quote
  #9 (permalink)  
Old 31st May 2009, 11:27 PM
marc's Avatar
Moderator
 
Join Date: Apr 2005
Posts: 6,042
Default

Quote:
Originally Posted by saphylia View Post
Personally I prefer, and use the 960 system, see 960 Grid System.
Both good! They achieve a similar goal and stop you from have to fudge around with floats and clears, when you actually want to be thinking about the design.

(FWIW, I only use the grid file in Blueprint.)

Meh 626: Sorry for the mini hijack, but if you were using 960 or Blueprint, you could have knocked the CSS and HTML for that page up in 5 mins and be confident it'd work in all browsers.
__________________
iStat for iPhone!
Over 12 million widgets and apps downloaded: iSlayer.com (RSS), iPhone apps: Bjango.com (RSS, Twitter)
Record TV easily: IceTV (RSS, IceTV iPhone app, Twitter)
Reply With Quote
Reply

Bookmarks

Tags
contents, css, div, fit, stretch

Click here to advertise on MacTalk!

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT +11. The time now is 12:09 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
MacTalk Media Pty Ltd is not responsible for the content of individual messages posted by others. Other content copyright MacTalk Media Pty Ltd.
Content Relevant URLs by vBSEO 3.3.0