Problems making the content area have a dynamic height

This is a discussion on "Problems making the content area have a dynamic height" within the Web Page Design section. This forum, and the thread "Problems making the content area have a dynamic height are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 2nd, 2007, 14:20
Junior Member
Join Date: Oct 2006
Location: UK
Age: 23
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Problems making the content area have a dynamic height

Hi guys,

I'm currently trying to turn this into XHTML/CSS:



The problem is that it needs to have a dynamic height, so I've no idea how to approach the problem.

The first step I'd say would be to create an image along the entire top that's about 5px high for the top of the box, and then a 1px high image for a repeating background.

The problem I've got now is with the bottom area, and how to get text over it without having to create an entirely separate div and put the content between the two (which would be pretty awful).

Thanks in advance for any advice, I'm really stuck on this!
Reply With Quote

  #2 (permalink)  
Old Aug 2nd, 2007, 14:31
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to RZX Developer
Re: Problems making the content area have a dynamic height

Hey mate do you want the XHTML/CSS version to look exactly like the image above?

wayne
Reply With Quote
  #3 (permalink)  
Old Aug 2nd, 2007, 14:35
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

You need 3 divs. One for the top, you content, and the bottom image.
Reply With Quote
  #4 (permalink)  
Old Aug 2nd, 2007, 14:46
Junior Member
Join Date: Oct 2006
Location: UK
Age: 23
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

@ RXZ - Pretty much yup, but I'd like it so that the height will adjust according to how much content is in there.

@ karinne - thanks for the reply, my main problem though is the difference between the content and the bottom image. I mean, the gradient in the content area means I can't put it into actual middle div, yet if it's on the bottom one there'll be a large gap.

Apologies if I've explained it badly, I usually do
Reply With Quote
  #5 (permalink)  
Old Aug 2nd, 2007, 14:54
Reputable Member
Join Date: Jul 2007
Location: UK, Essex
Age: 21
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to RZX Developer
Re: Problems making the content area have a dynamic height

The layout could be created in tables but like I keep getting told tables are not the best way of doing it but it would work but the gradient would have to be a set height due to getting it as a td background

Wayne
Reply With Quote
  #6 (permalink)  
Old Aug 2nd, 2007, 15:03
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Bah ... I didn't notice the gradient! Sorry! Ugh! I hate dealing with gradients and outer-glows .... It's not the most Web-page-friendly design.

You have to remember that what looks great in PS might not be suitable for web ... only print
Reply With Quote
  #7 (permalink)  
Old Aug 2nd, 2007, 15:11
Junior Member
Join Date: Oct 2006
Location: UK
Age: 23
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Ahh I see, thank you karinne, I might need to have a rethink of how I'm doing it then!

@ RZX - cheers dude, I'll consider using tables but I think I'd rather not if possible. Thanks again for the info though!
Reply With Quote
  #8 (permalink)  
Old Aug 2nd, 2007, 15:11
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

There are lots of variations, depending on how flexible you want your boxes to be, and how many effects.

I might write a tutorial on this, once I've got it working myself...

For now, check out this tutorial, which is the basis for my (completely flexible) method.
Reply With Quote
  #9 (permalink)  
Old Aug 2nd, 2007, 15:14
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Right ... but then ... how would you handle the outer glow on the borders AND the gradient?
Reply With Quote
  #10 (permalink)  
Old Aug 2nd, 2007, 15:26
Junior Member
Join Date: Oct 2006
Location: UK
Age: 23
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

That's a sweet site thank you, but like karinne said, doing the outer glow is one thing but doing the gradient is going to be a nightmare.

I think I'll just ditch the outerglow thing and have a solid 1px border and then an image background for the gradient. Or something.
Reply With Quote
  #11 (permalink)  
Old Aug 2nd, 2007, 15:28
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Quote:
Originally Posted by karinne View Post
Right ... but then ... how would you handle the outer glow on the borders AND the gradient?
I'm working on it.

With enough <div>s, you can do anything. Especially if you use display: table-cell;.
Reply With Quote
  #12 (permalink)  
Old Aug 2nd, 2007, 16:38
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

hmmm yeah but the display: table-cell isn't widely supported
Reply With Quote
  #13 (permalink)  
Old Aug 2nd, 2007, 17:45
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Quote:
Originally Posted by karinne View Post
hmmm yeah but the display: table-cell isn't widely supported
Well, not widely supported by IE.

But sometimes, depending on what you're doing, you can hack it with javascript for IE.

For this effect, however, I think display: table-cell is unnecessary.
Reply With Quote
  #14 (permalink)  
Old Aug 2nd, 2007, 18:12
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Well ... I can't wait to see this
Reply With Quote
  #15 (permalink)  
Old Aug 2nd, 2007, 22:00
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Actually, it was a lot easier than I thought. Here's a screenshot:



This is fully scalable (the box width is defined in ems), and won't break no matter how big the box (unlike "sliding doors" techniques). It uses nine images with a total file size of less than 2 Kb (with lossless compression).

The only limitation is that it only works on flat backgrounds. The images must not use transparency. If your page background is patterned, then this will break (at least slightly).

If you want, you can even add another gradient for the box heading.


How it works

In this example, I'm using a <dl> (but you don't have to). Here's my HTML code:

Code: Select all
<dl class="tip">
<dt>Benefits of a good grip</dt>
<dd>
<ul>
<li>More powerful smashes</li>    
<li>More accurate net shots and serves</li>
<li>Stronger smash defence, and ready for both sides</li>
<li>Deceptive strokes</li>
</ul>
</dd>
</dl>

I use javascript to add seven nested <div>s inside the <dl>, transforming the code into this:

Code: Select all
<dl class="tip2">    
<div><div><div><div><div><div><div>
<dt>Benefits of a good grip</dt>
<dd>
<ul>
<li>More powerful smashes</li>    
<li>More accurate net shots and serves</li>
<li>Stronger smash defence, and ready for both sides</li>
<li>Deceptive strokes</li>
</ul>
</dd>
</div></div></div></div></div></div></div>
</dl>
I then apply CSS background images to Snow White and the seven Dwarfs...er, the <dl> and the seven <div>s. You need four sides and four corners. The sides are all 1px wide or high and set to repeat, but the corners overlap the sides to make a soft drop shadow.

The order is important: the corners must be applied to the deeper four <div>s, because these will stack on top of the sides. You must also be careful to match the images so that the corners line up with the sides. This is easy if you are methodical about creating your source graphic.

The content will stretch the <dl> and <div>s that surround it. To make the effect visible, I add padding in the deepest <div>. The padding matches the size of each side image (not the corners, which are larger).

The gradient itself is just applied to the <dd> CSS background.

That's it. Simple, huh?



Last edited by MikeHopley; Aug 2nd, 2007 at 23:01.
Reply With Quote
  #16 (permalink)  
Old Aug 2nd, 2007, 23:20
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Actually, I might stop using the javascript to generate the extra markup, because it sometimes fails (page refresh cures it).

Either that, or I'll make it run again after a delay and check.

Last edited by MikeHopley; Aug 2nd, 2007 at 23:22.
Reply With Quote
  #17 (permalink)  
Old Aug 3rd, 2007, 01:28
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Hmmm ...yeah but the gradient is only at the very bottom as oppose to the OP's gradient starts from the very top and extends all the way down
Reply With Quote
  #18 (permalink)  
Old Aug 3rd, 2007, 06:17
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Quote:
Originally Posted by karinne View Post
Hmmm ...yeah but the gradient is only at the very bottom as oppose to the OP's gradient starts from the very top and extends all the way down
Picky, picky, picky! Use your imagination!

If you want me to make the gradient stretch with the height, I'm afraid that's asking too much. But you can just use a larger gradient. I don't think a stretchy gradient would look nice, anyway.




Before you complain about the orange title: it would just require one extra <div> to apply the gradient across the whole box.

Last edited by MikeHopley; Aug 3rd, 2007 at 09:07.
Reply With Quote
  #19 (permalink)  
Old Aug 3rd, 2007, 09:10
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

Note that the gradient can be:
  • Fixed to the bottom of the box
  • Fixed to the top
  • Starting at the box centre
  • Starting a fixed distance (in ems or pixels) from the box top.
The latter two require one extra <div> to ensure background colours match at both top and bottom.

If the box is smaller than the gradient image, then some of the gradient will be cut off (at top or bottom). If the box is larger, then some of the box will be shaded with (matching) flat colour.

Last edited by MikeHopley; Aug 3rd, 2007 at 09:17.
Reply With Quote
  #20 (permalink)  
Old Aug 3rd, 2007, 10:45
Junior Member
Join Date: Oct 2006
Location: UK
Age: 23
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems making the content area have a dynamic height

That looks awesome, thank you so much, I'll try and get my head around it and do it asap
Reply With Quote
Reply

Tags
css, xhtml

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to constrain the height of a dynamic table MrQuestions Web Page Design 3 Mar 15th, 2008 00:08
CSS - dynamic height div google Web Page Design 39 Dec 4th, 2007 15:33
Making a text area martyoo Web Page Design 4 Aug 29th, 2007 20:19
content area not expanding Lchad Web Page Design 19 Jan 29th, 2007 14:45
Making sure the height of both divs is = csa Web Page Design 8 May 3rd, 2006 18:22


All times are GMT. The time now is 19:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43