Jump to content


Photo

Making A CSS "container" Stretch To Fit The Screen


  • Please log in to reply
10 replies to this topic

#1 DanBeckett

DanBeckett

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Location:Lancs, UK

Posted 09 September 2006 - 02:14 PM

Basically my problem is described in the post, I'm trying to find a way to make the container on my new page fill the screen, I'm used to tables though where "height=100%" normally does the trick, however, I can't seem to figure this out at all :/ If anyone can offer any solution/point to a tutorial I would really appreciate it.

I'll probably also kick myself when it's sorted out, probably a really simple solution, normally is though, isn't it?

Thanks - Dan.

#2 Rory

Rory

    Jedi In Training

  • Members
  • PipPip
  • 378 posts
  • Gender:Male
  • Location:Hastings, Hawkes bay, New Zealand
  • Interests:Php, Html, Css, Javascript, ASP.NET, Photoshop, soccer, rigby, cricket, viticulture, Ruby#, C#, AJAX.

Posted 09 September 2006 - 03:32 PM

I am assuming you are talking about div containers. There is a workaround which I haven't played with much so I won't know how succesful it is but here you go: just add the following code to your CSS file:

body, html {width:100%; height: 100%;}

and then add this to style sheet:

.divcontainername {height: 100%;}

#3 dEcade

dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 09 September 2006 - 04:03 PM

It should work width height=100% IE is really bad with CSS stuff.

try something like this:

*
{
margin: 0px;
padding: 0px;
}

html
{
margin: 0 auto;
height: 100%
width: 100%
}

body
{
margin: 0 auto;
height: 100%
width: 100%
}

.divclass
{
margin: 0 auto;
height: 100%
width: 100%
}

#divid
{
margin: 0 auto;
height: 100%
width: 100%
}

Hope you can figure it out.

dEcade

#4 DanBeckett

DanBeckett

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Location:Lancs, UK

Posted 11 September 2006 - 10:25 AM

<st>Thanks I'll try these out - appreciate it :blush:</st>

OK, that's nearly sorted it... it is now stretching, although only for one screen length, then it stops :S.

(I've reuploaded the code again http://danbeckett.co.uk/blog.htm and http://danbeckett.co.uk/blog.css)

Thanks - Dan.

Edited by DanBeckett, 11 September 2006 - 10:37 AM.


#5 blackhawk_996

blackhawk_996

    Young Padawan

  • Members
  • Pip
  • 59 posts

Posted 12 September 2006 - 12:49 AM

Let me know if these are similar to what you are after? I added a footer just for general purpose. Also this is accomplished with no images as well which will make for rather quick load times. (It assumes your left content block will always have more content than the right, if not it;s easy enough to fix. Just change the container's background color to macth the other column. It validates as xhtml strict as well as css 1/2/3)



:)

Attached Files

  • Attached File  blog.htm   3.81KB   244 downloads
  • Attached File  blog.css   1.66KB   253 downloads


#6 greg

greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 12 September 2006 - 09:38 PM

There's no simple solution to this. I've tried every possible way and I've seen others try it. It's a widely known fact that there's no way to do this without using Javascript or some other over-complicated method.

Trust me, don't waste your time.

#7 DanBeckett

DanBeckett

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Location:Lancs, UK

Posted 13 September 2006 - 06:00 AM

Ah right thanks, looks like I'm back to tables for the time being then... D'oh!

#8 greg

greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 13 September 2006 - 11:14 AM

That doesn't mean you have to regress back to tables. There are alternatives... Why do you need the content to stretch all the way down? If you tell us why you want that, we can tell you other ways of doing it.

#9 blackhawk_996

blackhawk_996

    Young Padawan

  • Members
  • Pip
  • 59 posts

Posted 13 September 2006 - 01:16 PM

There's no simple solution to this. I've tried every possible way and I've seen others try it. It's a widely known fact that there's no way to do this without using Javascript or some other over-complicated method.

Trust me, don't waste your time.


So it's safe to assume that the layout I offered isn't close to what your after then...?

#10 greg

greg

    Jedi In Training

  • Members
  • PipPip
  • 499 posts
  • Location:New York City
  • Interests:Fine art, web and graphic design, naval architecture, chess, and sports.

Posted 13 September 2006 - 02:47 PM

I can't tell what you "offered" because you didn't show anything; just attached it to your post. Upload it and I'll see.

#11 Jem

Jem

    Young Padawan

  • Members
  • Pip
  • 93 posts
  • Location:England
  • Interests:Photography, design &amp; developing, walking, cycling, reading.

Posted 14 September 2006 - 02:58 AM

Don't forget the semi-colons in future, dEcade, you're missing a whole lot there..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users