Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2004, 06:40 PM
Authorized User
 
Join Date: Jun 2003
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kabe
Default position 2 relative <div> in switched order

hi

is it possible to do this:
<body>
<div style="margin:0 15% 0 5% 0;width:80%;">
<div id="2">body</div>
<div id="1">header</div>
<div>
</body>

must be displayed as:
header
body

Thus, places of #1 and #2 must be switched visual

I know this is possible when working with absolute position, but can't do this 'cause the height is variable of both <div>

kabe.be
 
Old November 23rd, 2004, 08:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I'm just curious... but why must you put the body before the header?

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 24th, 2004, 08:26 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Yes, it is possible. In fact you can put the content of the body in pretty much any order you want. In this case CSS positioning is what you're after. The header and the body are absolutely positioned, this makes their actual order in the source irrelevant.

Snib, the reasoning behind this is usually to show the visitor the most important content first, especially on low bandwidth connections.

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old November 24th, 2004, 11:24 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
quote:I know this is possible when working with absolute position, but can't do this 'cause the height is variable of both <div>
Quote:
quote:In this case CSS positioning is what you're after. The header and the body are absolutely positioned...
I think what our friend is trying to ask for is that no matter how large the two <div> elements are, they should appear in reversed order. In order to do this directly with CSS, you'd have to know a static measurement of the height of the header.

I wonder if there's a way to do this dynamically with JavaScript, by detecting the header <div>'s end.

Thanks for the explanation Rich, I never thought of that :-)

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 24th, 2004, 12:34 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> I know this is possible when working with absolute position, but can't do this 'cause the height is variable of both

Sorry, I didn't read that far! :-) That's the problem with looking at P2P posts when first waking up.

It can be done with positioning, methinks, The problem that you're encountering, no doubt, is overlapping the two elements in certain conditions. In which case some Javascript might be necessary, at least for IE, and maybe even for all browsers.

Do you have a link to the project?? This would help us better see what you're up against and help us to make better suggestions.


Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
<div> with a absolute position crmpicco Javascript How-To 0 August 30th, 2005 05:42 AM
Javascript with <div> aware Javascript How-To 3 August 25th, 2005 05:57 AM
hide the <div> crmpicco Javascript How-To 1 August 22nd, 2005 09:43 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.