Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

CSS & DIV relative alignment

Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Report post to moderator

Im kinda new to using DIVs for structuring my website (previously used the ancient and static prehistoric method of tables!).
It all seems pretty straight forwards but I have come across an issue with 'relative' positioning.

How do you make DIV alignment 'relative' to the other divs around it?
By that I mean if I have a DIV(a) that is top/left 0 and has a height of say 50px, and I want another
DIV(b) below it, which is 30px high.
I can set the top of DIV(b) as 50px but if the height of DIV(a) changes then DIV(b) will be wrong. How do I
say that I always want DIV(b)s top to be relative to the height of DIV(a)?

Here is a simple example of a DIV layout that gives me a 'header,'topnav','left nav','body' and a 'footer'.
If I changes the height of 'header' how could I move the top of 'leftnav' and 'topnav' without having to go
thoruhg the CSS and physically make the changes. Also I always want 'body' to be relative to ALL the other DIVs so that it is always inside the topnav, leftnav & foot space.

As my website gets more complex this would become more and more of an issue.

Cheers in advance


OK, getting a bit closer (I think)

But the problem I have here is that the leftnav is longer than the browser window size and the content div is below the rest of the page layout.
Posts: 67478
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question more than once. As you have re-posted this, I'll close this one.
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic