Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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 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 August 18th, 2004, 05:08 PM
Friend of Wrox
 
Join Date: Mar 2004
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
 
Old August 24th, 2004, 07:51 AM
Authorized User
 
Join Date: Aug 2004
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>


 
Old August 26th, 2004, 02:35 PM
Friend of Wrox
 
Join Date: Mar 2004
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.


 
Old August 26th, 2004, 11:21 PM
Authorized User
 
Join Date: Aug 2004
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.

 
Old August 27th, 2004, 05:03 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
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
 
Old September 5th, 2004, 02:16 PM
Friend of Wrox
 
Join Date: Mar 2004
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.





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





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