School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,355 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,947 people online right now. Registration is fast and FREE... Join Now!




Trying to make site vertically expandable

 

Trying to make site vertically expandable

Omelas0469

28 Jun, 2009 - 12:21 PM
Post #1

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
Hi all,

I'm new to the site and relatively new to HTML and CSS. I just started working on a web site for this non-profit group I've been volunteering for and I just finished doing the best I could on the homepage. Now that I have that set up, I want to make a Dreamweaver Template out of it so that the header, footer, and news column on the left side appear on every page. However, the issue I'm having right now is I can't seem to make it so that if I add extra news items in the news column, for example, the news column will expand and so that its parent divs will expand as well to accomodate it. I need it to work this way since every page will be usng the template and they can't all have the same heights due to variation in content. I've tried doing 'height:auto' for the wrapper and main divs but the white background and outside border disappear and some of the elements move out of place...

Here is the link so you can see what I have so far: The Mercy Project - Under construction
The CSS stylesheet can be found here: Style sheet

I'm looking for any suggestions as to how I can change my code to make it behave as described above.

Any other suggestions as to other ways I can improve what I've done so far are more than welcome since I'm totally new to this and want to do the best job I can.

As I said this is my first post in this forum so I hope I'm not leaving out any necessary details...

- Omelas


User is offlineProfile CardPM
+Quote Post


crazyjugglerdrummer

RE: Trying To Make Site Vertically Expandable

28 Jun, 2009 - 03:48 PM
Post #2

YOUR AD HERE
Group Icon

Joined: 7 Jan, 2009
Posts: 677



Thanked: 94 times
Dream Kudos: 425
My Contributions
I don't know anything about dreamweaver templates, but I know that an webpage will be as tall as it needs to be for its content (you don't need to set the height). If it gets bigger than the browser window it just scrolls, so no special height specifications needed. biggrin.gif
User is offlineProfile CardPM
+Quote Post

Omelas0469

RE: Trying To Make Site Vertically Expandable

28 Jun, 2009 - 06:30 PM
Post #3

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
That's not what I'm getting though. I have a main content div inside a wrapper div and the wrapper div doesn't seem to expand when the content inside the main div extend further that their container...
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Trying To Make Site Vertically Expandable

29 Jun, 2009 - 12:46 AM
Post #4

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
Seems to be working fine here, can you visually (screenshot of the actual issue) demonstrate the problem??

This could turn out to be a problem with using the float: attribute (i'm not sure if you're using it or not), but in that case, just add before the wrapper's </div>, <div style="clear:both"></div>.
User is offlineProfile CardPM
+Quote Post

neit

RE: Trying To Make Site Vertically Expandable

30 Jun, 2009 - 12:16 PM
Post #5

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
Are you testing in in firefox or IE.

This does appear because you are using fixed size div for the news box and main content area.
As far as I am aware IE will push a fixed height div down relative to
the content in it.
Firefox tends to push the content down but not the div so the content will
over run the the div when it supposed to contain it and mess up the design.

Removing the fixed height for the main div and newsbox should resolve your issue as mentioned already.
But it could mean that other parts look empty especially if the newsboxs
is bigger than the content area.

As your site has not got any content that is over running we cannot see an example of what is happening
User is offlineProfile CardPM
+Quote Post

ImportedNoob

RE: Trying To Make Site Vertically Expandable

30 Jun, 2009 - 01:16 PM
Post #6

New D.I.C Head
*

Joined: 29 Jun, 2009
Posts: 7



Thanked: 1 times
My Contributions
Find all of the containers that you want to be able to expand
Replace the height with a min-height attribute that has the same value as height


Layouts are almost always easier to do using html tables rather than css. You'll get what you expect 99 times out of 100.

This post has been edited by ImportedNoob: 30 Jun, 2009 - 01:22 PM
User is offlineProfile CardPM
+Quote Post

neit

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 02:14 AM
Post #7

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
CODE
Layouts are almost always easier to do using html tables rather than css. You'll get what you expect 99 times out of 100.


This is not recommended unless your using tablature data.
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 02:20 AM
Post #8

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
QUOTE(ImportedNoob @ 30 Jun, 2009 - 01:16 PM) *

Layouts are almost always easier to do using html tables rather than css. You'll get what you expect 99 times out of 100.

As said above that is not a good approach to web development, using something less supported because it's "easier". Which, btw, if you learned XHTML and CSS correctly, it's not.

Shall we just wait and see what the OP says about the already given solutions?
User is offlineProfile CardPM
+Quote Post

Omelas0469

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 12:41 PM
Post #9

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
You can find an example of the problem here.

I'm testing with both Firefox and IE.

I placed the clear:both div right before 'wrapper's closing div tag and it made wrapper extend to include the content which helped, thanks Mage.

Other than that several problems still arise. I change the height attributes to min-height for the main div and the newsBox div but it didn't change anything.

Here are the problems I'm trying to fix:
  • I want the newsBox to have at least the height it has now, but I want it to extend with the 'main' div if ever the 'main' div is expanded due to its content.
  • I want the footer to be at the bottom of the content, i.e. the 'main' div at all times, so if the 'main' div is extended vertically, the footer should still be at the bottom of it.
  • I don't want the "Home | Contact Us | FAQ | Privacy Policy" links in the footer to be moved when the content overflows the 'main' div.

I've changed the height attribute to min-height for both the newsBox and the 'main' div but as you can see, this hasn't changed anything.

Any more ideas?
Thanks for the help you've provided me with this far.
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 12:51 PM
Post #10

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
For problems number 2+3 (footer related) just move the footer div above the div with clear: all on it smile.gif

Your first "problem" would need to be done with Javascript as there's no other way when using a floated div. However I think it looks fine just the way it is.

Oh and, you're welcome smile.gif
User is offlineProfile CardPM
+Quote Post

Omelas0469

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 02:53 PM
Post #11

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
Alright I got it working as I want it to by following Mage's tip (thanks again).

Now I'm going to look into how to write a javascript code that assign my newsBox a height so that it just touches the footer. I'd have thought that there'd be a way to give a div a min height and have it take on the height of it's parent div as well but I suppose I need a conditional statement and that's why javascript is necessary...

Thanks to everyone who contributed!
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Trying To Make Site Vertically Expandable

1 Jul, 2009 - 11:09 PM
Post #12

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
No problem!

You'd just do something like:
CODE
var newsBox = document.getElementById('newsBox');
var mainBox = document.getElementById('mainBox');
if(mainBox.style.height > newsBox.style.height)
   newsBox.style.height = mainBox.style.height;

User is offlineProfile CardPM
+Quote Post

neit

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 05:22 AM
Post #13

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
The following should do all three without using javascript.
You just need to be creative on how you cut the images.
You will need to tweak it alittle to include your menu section but that should be easy enough to do.

html code

CODE

<html>
<head>
<title>The Mercy Project</title>
<link href="test.css" rel="stylesheet" type="text/css" /></link>
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="leftcolumn">
left column content here
</div>
<div id="content">
right column content here
</div>
<div id="footer"></div>
</div>
</body>
</html>


CSS code
CODE


body {
font-size: 0.7em;
font-family: verdana, arial, sans-serif;
text-align: center;
}

#container
{
width: 1002px;
margin: 20px auto;
background-image: url(images/bg.jpg);
text-align: left;

}



#header
{
height: 165px;
width: 1002px;
background-image: url(images/header.jpg);
}



#leftcolumn
{
float: left;
width: 185px;
margin: 0;
padding-bottom: 20px;
padding-left: 10px;

}

#content
{
margin-left: 210px;
padding: 3em;


}

#footer
{
clear: both;
height: 57px;
background-image: url(images/footer.jpg);
width: 1002px;
}


You can see an example here



This post has been edited by neit: 2 Jul, 2009 - 05:46 AM
User is offlineProfile CardPM
+Quote Post

RudiVisser

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 09:37 AM
Post #14

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
Using a margin... That's a strange way of accomplishing the task, but good idea nontheless smile.gif
User is offlineProfile CardPM
+Quote Post

Omelas0469

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 11:54 AM
Post #15

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
Wow thanks for all the great responses.

It's working perfectly now thanks to all your suggestions. I opted to use javascript to have a clean and clear solution that only took a couple of lines of code:

CODE

<script type="text/javascript">
    var maxHeight = Math.max(document.getElementById("newsBox").offsetHeight, document.getElementById("main").offsetHeight);
    maxHeight -= 10;
    document.getElementById("newsBox").style.height=maxHeight+"px";
</script>


Now the only issue I'm having is that the background image I'm using repeats itself when the newsBox is made to expand and it looks weird... I've been trying to think of a way to do this. I obviously don't want to include a separate style sheet for every page to link to a different image... I would like to find a way to size the image dynamically based on the size of the newsBox but without simply repeating itself. Is there any way to make it stretch?

The only solution I can think of at the moment is to stop using a background image for the div and instead just place an image there which I can warp using the height attribute and then place the text above the picture. I would like to find a more elegant solution though.

Any suggestions?
neit, how did you make the picture expand for the newsBox in your sample?
User is offlineProfile CardPM
+Quote Post

Quin

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 12:27 PM
Post #16

D.I.C Head
Group Icon

Joined: 16 Oct, 2008
Posts: 212



Thanked: 9 times
Dream Kudos: 50
My Contributions
The area that has the repeating background image, add...
CODE
background-repeat: no-repeat;


Should do it.

You can make it repeat vertically or horizontally by using repeat-y or repeat-x, respectively.
User is offlineProfile CardPM
+Quote Post

Omelas0469

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 02:02 PM
Post #17

New D.I.C Head
*

Joined: 27 Jun, 2009
Posts: 14


My Contributions
If I set it to no-repeat, the image appears once in the div and the rest of the div beneath the image is whitespace. What I'm trying to do is have the background image vertically stretched so that it covers the div without repeating itself.

This post has been edited by Omelas0469: 2 Jul, 2009 - 02:02 PM
User is offlineProfile CardPM
+Quote Post

neit

RE: Trying To Make Site Vertically Expandable

2 Jul, 2009 - 02:41 PM
Post #18

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
The sample I made consists of 3 images.
1) The header which includes the menu and the top of the sidebar
2) The main bg image is a small strip of the site from the left border
to the right about 10px in height.

3) The footer includes the a small part at the bottom of the sidebar.

If you use firefox you should be able to right click on each section and select
view background image. This will show you the 3 images.
The actual main content and side bar background covers the whole site but because the header and footer images are over the top you do not
see and it appears seamless.

Everytime you run into a new problem it would be best to include a like so we can see what's happening.

This post has been edited by neit: 2 Jul, 2009 - 02:42 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 07:28PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month