Solved

Div layered above another div????

Posted on 2006-06-29
5
440 Views
Last Modified: 2012-06-21
I basically have one div tag that is going to over lap another div tag...
<div>
<div id='inner'>
Some dynamic content, can be any size.....
</div>
</div>

I need to have the outer div tag lie on top of the inner div tag. With a dashed border directly on top of it.. The same length and height of the inner div tag.
So if the inner div is 100 X 100...The outer div needs to be 100 X 100 directly on top of the inner with nothing but a dashed border...
Any help much appreciated
0
Comment
Question by:nywebsol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 17014451
Can i ask you why you want the outer div to be on top if it's transparent?
Is it to stop the user from interacting with the content of the inner div?

I came up with the code that follows which works fine in IE, FF and Opera...
All browsers still allow text selection and FF even allows interaction with the form controls for some strange reason.
I had to add an additional div to make it work in FF and use a hack for IE that always needs special treatment.
And i added a transparent/black checkered backgound image to the outer div to show that it is on top...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8'/>
<title>Test</title>
<style type="text/css">

body {
  background: #eee;
  color: #111;
}

#outerer {
  position: relative;
  z-index: 1;
}

* html #outerer {
  position: static;
}

#outer {
  border: 1px solid black;
  background: url(http://www.serger.biz/ee/transparent_checkers.png);
}

#inner {
  position: relative;
  z-index: -1;
  color: red;
  font-size: 200%;
  font-weight: bold;
}

</style>
</head>
<body>

<div id='outerer'>
<div id='outer'>
<div id='inner'>
Some dynamic content, can be any size.....
<input type="button" value="hello">
<input type="text" value="world">
</div>
</div>
</div>

</body>
</html>
0
 

Author Comment

by:nywebsol
ID: 17018846
my problem is that my width is set to a strict width for the page. Once we have any border around a div tag... it makes it wider. that is why i am trying to get something to appera on top of the inner area
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 250 total points
ID: 17023749
having your "outer" div on top of the "inner" div won't change the way the widths of elements are calculated.

set your width on a block element that does not have a border and use the default width ("width: auto") for the block element that has the border:

<div style="width: 10em;">
<div style="border: 10px solid red;">
Some dynamic content, can be any size.....
</div>
</div>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question