Also - if you could link us to a page, that would be great!
:)
Main Topics
Browse All TopicsI have the following divs and stylesheet
my problem is the following:
firefox:
when the current div is clicked, the new one shows as supposed to, but the current one sits underneath the same size but as whitespace underneath the new div that is shown. there is unnecessary whitespace until the last div that brings up the first main div again, then all the whitespaces disappear and display:none; properly again.
i dont get this problem in ie tho ?
anyone care to take a look and explain ? fastest most informative answer to the situation receives the points !
<div id="main_pic" onClick="document.getEleme
document.getElementById('3
<div id="3" class="intro" onClick="document.getEleme
document.getElementById('4
<div id="4" class="intro" onClick="document.getEleme
document.getElementById('m
.hide {
display: none;
visibility:hidden;
}
.intro {
display: none;
}
.show {
width:100%;
height:220px;
background: #FFFFFF url(logo1.jpg) no-repeat;
}
#main_pic{
width:100%;
height:220px;
background: #FFFFFF url(campsbay.jpg) no-repeat;
}
thx
Brad
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This is a simple element rotator that just needs a few simple adjustments. Before I go into discussing this, when creating effects like this, you have to constantly think of "consolidation." The approach I took here does a bit of consolidation that also serves to simplify your document. Here we go...
First off, we'll make a couple of adjustments to your styles like so:
<style type="text/css">
.show {
display:none;
height:220px;
background: #FFFFFF url(logo1.jpg) no-repeat;
border: 1px solid red;
}
#main_pic{
height:220px;
background: #FFFFFF url(campsbay.jpg) no-repeat;
border: 1px solid green;
}
</style>
Note: I just added a border so I could see the divs. You don't need to set a div to 100% because it'll do that by default. Notice also that I set the 'show' class to display:none. This will make the "3" and "4" divs invisible when you load the page, which is the desired result. 'main_pic' gets no visibilty properties so it'll show at page load.
For the rotator effect, with some simple javascript, here's the function and the div declarations:
<script type="text/javascript">
function rotateDiv(curDivID,nextDiv
var curDiv = document.getElementById(cu
var nextDiv = document.getElementById(ne
curDiv.style.display = "none";
nextDiv.style.display="blo
}
</script>
<div id="main_pic" onClick="javascript:rotate
<div id="3" class="show" onClick="javascript:rotate
<div id="4" class="show" onClick="javascript:rotate
Notice in the div declarations, I took all the JavaScript logic out of the onClick of each and assigned it to a function. This made them much simpler but also if you ever want to change the show/hide behavior, you can do it one place. Also, the function is set up so you can be flexible with the order of the divs showing and hiding (ie, show div 4 before div 3). But in general, from a code maintenance standpoint, shared or common functionality should be moved to a central function that'll handle behavior. It's a lot easier to code in a single area than in multiple ones.
I put it all together here: http://www.iarchitec.com/t
GoofyDawg
Thanks to you both so far:
Neester yours doesnt seem to be helping at all
Goofydawg, nearly working, but dont like the calling of the function !
I have posted the files up to : http://campsbay.com/css-ne
Take a look in IE seems to work fine, then have a look at firefox: keeps on holding the space, maybe some wrong code in the css, css file at : http://campsbay.com/css-ne
Thx in advance !
Rgds
Brad
Why not a function? From a code maintenance standpoint, it's much more manageable.
But if you still want to do all your functionality within the onClick, that's fine. You'll still solve the problem by giving all the numbered divs the "show" class name that I wrote. Then all you'll have to do is set the display property in your onClick. You needn't mess with className. It's unnecessary, considering display does what you need.
GoofyDawg
It's not technically incorrect to use numbers for ids (since they're strings), but from a nomenclature standpoint, it certainly does make things unclear. By convention, ids and classes should be as descriptive as possible. Having said that though, Yahoo creates class and id names that are incredibly short, damn the descriptions, only because they need to save on page load. Their argument is that even 1 byte generates millions of bytes in traffic per day! So I guess nomenclature really boils down to what's optimal for your application.
GoofyDawg
GoofyDawg, please check your sources before posting information that can be misleading.
ID and NAME MUST start with a letter. That's in the specs:
http://www.htmlhelp.com/re
http://www.w3.org/TR/html4
The "class" attribute is different (cdata-list).
http://www.w3.org/TR/html4
I must say the following:
Thx for both of your help and answers.
I found a solution myself:
nested all the <div id=\"1/2/3/4\"> etc...
within the <div id=\"main_pic\">
now, no more whitespace in mozilla, and ie still works perfectly
just used main_pic as a holder, and ran through the numbered ones
(I am using letters now, thanks for that -> but as an example, showing which is where, of what was posted already)
Business Accounts
Answer for Membership
by: neesterPosted on 2005-06-15 at 17:08:06ID: 14227073
just try this instead:
ntById('ma in_pic').s tyle.displ ay='none'; ').style.d isplay=''" >1st image</div> ntById('3' ).style.di splay='non e'; ').style.d isplay=''" >3</div> ntById('4' ).style.di splay='non e'; ain_pic'). style.disp lay=''">4< /div>
<div id="main_pic" onClick="document.getEleme
document.getElementById('3
<div id="3" class="intro" onClick="document.getEleme
document.getElementById('4
<div id="4" class="intro" onClick="document.getEleme
document.getElementById('m
See if that works out.
I have never had any issues with that code.