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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

CSS & DIV relative alignment

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
HI,

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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic