|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
css layers
I've tried different implementations, but none seem to be working.
I have two images crossing over each other using two position: absolute divs. When I click on the one behind using an onClick javascript function, I want that div's z-layer value to change, but none of the sites are helping me. How do I do this? |
|
#2
|
||||
|
||||
|
I've made a small example of hot swapping z-indices. It uses the onclick event handler to call a small function.
cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. Ask a better question, get a better answer. |
|
#3
|
||||
|
||||
|
gary,
that's a great little script! thanks, Greg
__________________
new jersey web design |
|
#4
|
|||
|
|||
|
Thanks, that really clears everything up. I think most of the tutorials I saw used .z-index: , which doesn't work.
|
|
#5
|
||||
|
||||
|
Quote:
Examples: z-index ⇒ zIndex; background-color ⇒ backgroundColor; margin-top-width ⇒ marginTopWidth. cheers, gary Last edited by kk5st : May 3rd, 2004 at 12:48 PM. |
|
#6
|
|||
|
|||
|
Maybe there's some error in my code I'm not catching, but I'm trying to do the same thing putting two images in the div's and switching them. Is there anything wrong here? I get the alert sometimes, but it never does the switch.
<style type="text/css"> /*<![CDATA[*/ <!-- #first { position: absolute; left: 10px; z-index: 2; width: 640; height: 480; bgcolor: #f88; } #second { position: absolute; left: 70px; z-index: 3 width: 640; height: 480; bgcolor: #88f; } body { padding: 0; margin: 0; font: 100% arial, sans-serif; color: #333; background-color: white; } p { font-size: 1em: } #div1 { position: absolute; top: 100px; left: 100px; height: 150px; width: 150px; background-color: #f88; } #div2 { position: absolute; top: 150px; left: 150px; height: 150px; width: 150px; background-color: #88f; } /*]]>*/ --> </style> <script type="text/javascript"> function toFront(onBottom) { alert(onBottom + "Ugg"); document.getElementById(onBottom).style.zindex = '2'; document.getElementById(onTop).style.zindex = '1'; } </script> <body> <div id="div1" onClick="toFront('div1','div2')"> <img name="headerpiece" src="images/theroyalbangs.jpg" width="100%" height="100%"> </div> <div id="div2"> <img name="centerpiece" src="images/sam1.gif" onClick="centerpiece.src='images/sam2.gif'"> </div> </body> |
|
#7
|
|||
|
|||
|
Oops, in my code I really do pass the function two parameters...
|
|
#8
|
||||
|
||||
|
Before making all the changes, use my code verbatim. Then, you can add/modify one thing at a time. If it breaks, you'll know what broke it.
cheers, gary |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > css layers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|