multiple overlapping divs?

This is a discussion on "multiple overlapping divs?" within the Web Page Design section. This forum, and the thread "multiple overlapping divs? are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 19th, 2007, 06:54
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
multiple overlapping divs?

It's a crazy question, and I think I already know the answer, but I'm going to ask anyway. Is this possible?
Code: Select all
<div class="a">This is div A.
   <div class="b">This is div B and still div A.
</div class="a">This is only div B.
      <div class="c">This is div B and div C.
   </div class="b">
          This is only div C.
       </div>
Reply With Quote

  #2 (permalink)  
Old Apr 19th, 2007, 10:06
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Nope, not possible. What were you intending to do with that code? You could place div's over each other using absolute positioning anyway...
Reply With Quote
  #3 (permalink)  
Old Apr 19th, 2007, 14:59
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Quote:
Originally Posted by Ryan Fait View Post
What were you intending to do with that code?
Picture 3 side-by-side floated divs... the center div contains text (height will vary), the left and right ones contain navigational elements. If I could control overlapping divs, I could vertically center the nav elements without resorting to a table. I think I've become obsesses with eliminating tables! :crazy:
Reply With Quote
  #4 (permalink)  
Old Apr 19th, 2007, 16:03
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: multiple overlapping divs?

Just define your three divs one after the other.

Float them all left and control the width of each to suit your total layout width.

Use margin to control space between divs.
Reply With Quote
  #5 (permalink)  
Old Apr 19th, 2007, 16:49
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,646
Thanks: 0
Thanked 7 Times in 7 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: multiple overlapping divs?

http://www.newguyinennis.com/samples...yout_3_column/
__________________
I've got <style> and .class
Reply With Quote
  #6 (permalink)  
Old Apr 19th, 2007, 17:27
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

I get how to stack divs side-by-side. I get how to use width and margins. What I'm trying to do is vertically center small nav images (arrow left and arrow right) in the left and right div - regardless of how the height of the middle div may vary.
Reply With Quote
  #7 (permalink)  
Old Apr 19th, 2007, 17:37
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,646
Thanks: 0
Thanked 7 Times in 7 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: multiple overlapping divs?

background: url("foo.jpg") left center no-repeat; no? that will keep the background centered in a div regardless of its height.
__________________
I've got <style> and .class
Reply With Quote
  #8 (permalink)  
Old Apr 22nd, 2007, 00:17
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Quote:
Originally Posted by moojoo View Post
background: url("foo.jpg") left center no-repeat; no? that will keep the background centered in a div regardless of its height.
I didn't know that, and I'm happy new to have learned something, but...

I can't link using a background image, though, can I? I'll still need a foreground element to serve as link/the nav element. Can I put a clear.gif in the foreground and set its height and width to 100% and have it be the clickable link/nav element? I haven't had great success in the past with setting elements to 100% height and actually have them obey (especially from a cross-browser standpoint.) If you can tell me how to do that, I'll be thrilled!
Reply With Quote
  #9 (permalink)  
Old Apr 22nd, 2007, 00:58
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Code: Select all
a {
  width: 200px;
  height: 200px;
  background: url(img.jpg) no-repeat;
  display: block;
}
You'll need something to hide the text, text-indent: -5000; will do the trick, but as I recall, you can't use that on anchors. So you'll have to select it's parent or something to set the text-indent.
Reply With Quote
  #10 (permalink)  
Old Apr 22nd, 2007, 01:11
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

But you're specifying a height for the anchor... The whole point is that the height will vary. Sometimes 200px will be too much, other times not enough.

I don't understand your point about hiding the text. Unless we're getting back to the whole "never ever use images for navigation" thing. But this is just a simple previous/next arrow thing - and I'll be using alt and title text, so why not just use a clear gif as the anchor?

Hey, wait a minute - what about setting the height of the image to something ridiculously high, then setting overflow on the container to hidden?
Reply With Quote
  #11 (permalink)  
Old Apr 22nd, 2007, 01:41
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Quote:
Originally Posted by Donny Bahama View Post
Hey, wait a minute - what about setting the height of the image to something ridiculously high, then setting overflow on the container to hidden?
Nevermind. That definitely doesn't work.
Reply With Quote
  #12 (permalink)  
Old Apr 22nd, 2007, 01:53
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

OK. Could someone please just say, "Give it up, Donny! The only way to do that currently is using a table!"
Reply With Quote
  #13 (permalink)  
Old Apr 22nd, 2007, 01:57
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Can you show me what you're doing with a table? I'll tell you how to do it with CSS.
Reply With Quote
  #14 (permalink)  
Old Apr 22nd, 2007, 02:30
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Happy to. Here's a link: http://stickpuppy.com/dhs57/yearinre...?event=1010601

Notice the event text. Click the next arrow 4 or 5 times (you could click the previous arrow, but those images won't be preloaded for you) and watch how the event text changes in quantity, ergo height. But the next and previous arrows stay vertically centered, regardless of the height of the middle (text) div.

If you must view source, know that I have overhauled most of this page and eliminated tables everywhere but in the area in question. If I need to use a single row table to do this, so be it, but I thought that since it was a single row table, I should be able to replace it with a div-based layout.
Reply With Quote
  #15 (permalink)  
Old Apr 23rd, 2007, 03:52
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Sorry for taking so long. I forgot about this...

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>

		<script type="text/javascript">

		</script>

		<style type="text/css">
			body {
				margin: 0;
				padding: 15px;
			}
			.box {
				position: relative;
				height: auto;
				width: 200px;
				background: #ccc;
			}
			.box p {
				margin: 0 35px;
			}
			.box p.leftarrow {
				position: absolute;
				left: 0;
				top: 0;
				height: 100%;
				width: 30px;
				margin: 0;
				text-indent: -5000px;
				background: #aaa url(arrowleft.gif) no-repeat 50% 50%;
			}
			.box p.rightarrow {
				position: absolute;
				right: 0;
				top: 0;
				height: 100%;
				width: 30px;
				margin: 0;
				text-indent: -5000px;
				background: #aaa url(arrowright.gif) no-repeat 50% 50%;
			}
			.box a {
				position: absolute;
				width: 30px;
				height: 100%;
				display: block;
			}
		</style>

		<title>Untitled</title>

	</head>
	<body>

		<div class="box">
			<p class="leftarrow"><a href="#">Left</a></p>
			<p>Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text </p>
			<p class="rightarrow"><a href="#">Right</a><p>
		</div>

	</body>
</html>

This was kind of tricky I like tricky things!

Last edited by Ryan Fait; Apr 23rd, 2007 at 03:54.
Reply With Quote
  #16 (permalink)  
Old Apr 23rd, 2007, 04:08
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

You cheated! I don't want to use javascript. (Sorry, should've specified.)
Reply With Quote
  #17 (permalink)  
Old Apr 23rd, 2007, 04:11
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Quote:
Originally Posted by Ryan Fait View Post
show me what you're doing with a table? I'll tell you how to do it with CSS.
Reply With Quote
  #18 (permalink)  
Old Apr 23rd, 2007, 04:17
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

There's no JavaScript. It's just my test page layout. Ignore the script tags.
Reply With Quote
  #19 (permalink)  
Old Apr 23rd, 2007, 04:21
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

DOH! Should've looked more closely! OK - I'll check that out, then. Man, if you pulled that off... WOW!
Reply With Quote
  #20 (permalink)  
Old Apr 23rd, 2007, 05:00
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multiple overlapping divs?

Haha. I have a strange understanding of CSS, and I just can't figure out why people have problems with it.

*brushes off shoulders... lol
Reply With Quote
Reply

Tags
overlapping divs

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Overlapping avoidable? Xyis Web Page Design 3 Mar 12th, 2008 17:53
Random position of multiple divs benreynolds4 JavaScript Forum 3 Feb 22nd, 2008 04:17
[SOLVED] overlapping divs :-( danny322 Web Page Design 7 Dec 18th, 2007 12:58
Overlapping text timmytots Web Page Design 1 Oct 11th, 2006 19:47
Div's overlapping fluerasa Web Page Design 2 Oct 8th, 2006 10:09


All times are GMT. The time now is 13:07.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43