Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2004, 05:08 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default superimpose <DIV> blocks

we can superimpose two <DIV> blocks using 'position:absolute'
can we do it trick more gracefully with some css1 or css2 thing without 'position:absolute' ?

i m just asking.
__________________
`~@#\^%&*/\.<.\/-|+|_!:;..=?>
PHP, SEO | anshul shrivastava | mediasworks.org | FB
Reply With Quote
  #2 (permalink)  
Old August 24th, 2004, 07:51 AM
Authorized User
 
Join Date: Aug 2004
Location: Chicago, IL, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To superimpose two <DIV> tags you can use the z-index property. Position the <DIV> tags wherever you want on your page using position:absolute and the top/left commands and then use the z-index property to order the divs anyway you want. You can superimpose as many <DIV> tags on top of each other as you want as long as you keep increasing their z-index value. The <DIV> with the highest z-index value will appear on top. Like so:

Code:
<style type="text/css">
.floater {
    position:absolute;
    width:160px;
    }

#bottom {
    background:yellow;
    }

#middle    {
    z-index:1;
    top:25px;
    background:blue;
    }

#top    {
    z-index:2;
    top:35px;
    background:green;
    }
</style>

[...]

<div id="top" class="floater">This is on the top</div>
<div id="middle" class="floater">This is in the middle</div>
<div id="bottom" class="floater">This is on the bottom</div>


Reply With Quote
  #3 (permalink)  
Old August 26th, 2004, 02:35 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

thank u.
but you are fixing the <DIV>s ( absolute positioning );
this is not desired.


Reply With Quote
  #4 (permalink)  
Old August 26th, 2004, 11:21 PM
Authorized User
 
Join Date: Aug 2004
Location: Chicago, IL, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My apologies. There's no other way that I'm aware of to position div tags without using the 'position' attribute of the divs.

Reply With Quote
  #5 (permalink)  
Old August 27th, 2004, 05:03 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Why is absolute positioning less graceful? What is the effect that you desire? Can you show us an example?

Divs can overlap eachother without absolute positioning. Specify relative positioning and use margins or offset properties to control the position and the z-index to control the layering. Relative positioning means the element doesn't leave the normal flow, whereas absolute positioning does.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
Reply With Quote
  #6 (permalink)  
Old September 5th, 2004, 02:16 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

idea behind relative positioning is to let DIVs come freely, float or adjust 'top to bottom' of page.
a simple mistake in absolute positioning, though can make DIVs 'shunt' when browser-type change.

i've to overlap DIVs for http://www.mediasworks.com/webstory/cghost/home.htm

i don't if i've some good way2super-impose. that i meant.
no a big problem, then and now, though.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
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
sizeable <div> johnjohn Javascript How-To 1 December 8th, 2004 08:28 PM
scrolling <DIV> anshul Javascript How-To 12 August 4th, 2004 09:51 AM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM



All times are GMT -4. The time now is 11:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.