473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Overlapping div is not overlapping

I am very new to CSS and am trying to set up 2 divs in the same space
on the page. The idea is that div1 will be an informational message
only displayed sometimes. When there isn't a message to be put there,
then div1 will be hidden and div2 content will be visible. The problem
I am having with this is that the content is still lining up right
beneath each other. If I make div1 hidden, then there is just white
space where it used to be.

Please help me understand what I'm doing wrong and how to make it do
this. If I'm completely off track, please let me know.

Kalvin

**code starts here **

<table width="200" height="100%" border="0" cellpadding="0"
cellspacing="5">
<tr>
<td>
<div id="div1" style="position:relative; top:0; left:0;
float:none; z-index:10;">
The admin lunch room will be closed on Friday
</div>
<div id="div2"
style="position:relative; top:0; left:0; float: none; z-index:1; ">
Secondary Story </div>
</td>
</tr>
<tr>
<td height="190">
<div id="Weather" style="position:relative; width:175px;
z-index:1; height: 195px; overflow: hidden;">
Weather goes here!
</div>
</td>
</tr>
</table>

Sep 7 '05 #1
2 19721
Kalvin wrote:
I am very new to CSS and am trying to set up 2 divs in the same space
on the page.
You are using position: relative - which renders the page as normal, and
then sifts elements according to the left/right/top/bottom properties
without altering the flow.

You need absolute positioning to place two elements in the same spot, this
positions elements from the top/left/right/bottom edges of the containing
block (nearest ancestor element that is not position: static, or the
viewport if no such element exists).
The idea is that div1 will be an informational message
only displayed sometimes.
So why not change the text instead? Preferably on the server so that it
won't fail if JavaScript or CSS is not available.
When there isn't a message to be put there,
then div1 will be hidden and div2 content will be visible.
What you probably want to do then (if you don't go with my suggestion above
regarding altering the text), is to toggle the display property of the
element between the default and "none". This will remove it from normal
flow.
I am having with this is that the content is still lining up right
beneath each other. If I make div1 hidden, then there is just white
space where it used to be.


Invisible things still take up space.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Sep 7 '05 #2
Kalvin wrote:
I am very new to CSS and am trying to set up 2 divs in the same space
on the page. The idea is that div1 will be an informational message
only displayed sometimes. When there isn't a message to be put there,
then div1 will be hidden and div2 content will be visible. The problem
I am having with this is that the content is still lining up right
beneath each other. If I make div1 hidden, then there is just white
space where it used to be.

Please help me understand what I'm doing wrong and how to make it do
this. If I'm completely off track, please let me know.


Inside the cell (are you sure you really want/need to use a table?),
place a Relatively positioned DIV containing the two messages in an
Absolutely positioned DIV each. Forget about z-index here; it is not
necessary. Don't use the display property, use the visibility property
instead. Allow the initial one to have the default of 'visible' and the
secondary one to have "visibility:hidden;". Then apply a mechanism to
trigger the switch to make the initial div hidden and the secondary div
visible.

--
Gus
Sep 8 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: km | last post by:
Hi all, python re module deals with only nonoverlapping matches. how to go for if i want to find out overlapping matches and their span ? regards, KM
1
by: André Søreng | last post by:
With the re/sre module included with Python 2.4: pattern = "(?P<id1>avi)|(?P<id2>avi|mp3)" string2match = "some string with avi in it" matches = re.finditer(pattern, string2match) .......
11
by: Max M | last post by:
I am writing a "find-free-time" function for a calendar. There are a lot of time spans with start end times, some overlapping, some not. To find the free time spans, I first need to convert the...
3
by: Phil Sandler | last post by:
All, I have a table with start and end dates/times in it, and would like to be able to calculate the number of hours represented, accounting for overlapping records. Note that I am looking...
4
by: Simon Elliott | last post by:
Is there an equivalent of std::copy which works on STL containers for overlapping ranges? -- Simon Elliott http://www.ctsn.co.uk
0
by: Bruce | last post by:
Hello, Back in the Access 97 days, if I had two texboxes on a form or report that overlapped, and I selected both and did a Format, Align, Top from the menu in design view, the controls would...
4
by: David Thorp | last post by:
New to this list (first post), and relatively new to C, so hi everyone... If anyone can help me with this I'll be most grateful... The following code is from a rather elaborate (for me) program...
4
by: Charlie Brown | last post by:
I have a form with 2 custom controls that can be dragged around by a user. How can I check if they overlap each other without performing some kind of Collision detection on them? Is there...
4
by: =?ISO-8859-15?Q?Jean=2DFran=E7ois?= Lemaire | last post by:
Hello all, I'm learning C and I still am struggling to understand some basic concepts. For example, I read in the standard that with functions such as strcpy, 'If copying takes place between...
3
by: cowboyrocks2009 | last post by:
Hi, I am trying to write a Java program to plot rectangles with different colors side by side non overlapping but unfortunately I am unable to do that as of now. Suppose I want to create 3...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.