473,395 Members | 1,641 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,395 software developers and data experts.

Moving Div with javascript isn't respecting overflow

3
Hi all!

I have some pictures on a page that I'm moving around with javascript. I'm just setting the style.top member. I don't want the image to overflow the parent container if I move it to a 'bad' position. I'm setting the overflow attribute in the style, but I'm still seeing the image go outside of the boundaries. Any idea's what I'm missing?


Expand|Select|Wrap|Line Numbers
  1.     var Obj = document.getElementById( "imageId1" )
  2.     if( Obj )
  3.     {
  4.         var currPosValue = 0;
  5.         var currPosStr = Obj.style.top.replace('px','');
  6.         if( currPosStr )
  7.         {
  8.             var currPosValue = parseFloat( currPosStr );
  9.         }
  10.         currPosValue += 2;
  11.         thumbObj.style.top = currPosValue + "px";
  12.     }
  13.  
Expand|Select|Wrap|Line Numbers
  1.     .Pane1 {
  2.             position:absolute; 
  3.             top: 38px;
  4.             left: 774px;
  5.             float:right;
  6.             width:188px;
  7.             height:500px;
  8.             margin: 0px 0px 0px 0px;
  9.             border: 1px solid;
  10.             text-align:left; 
  11.             background-color: white; 
  12.             z-index:1 
  13.             overflow:hidden;
  14.         }
  15.  
  16.     .PaneImage{
  17.             position: absolute;
  18.             width:81px; 
  19.             height:72px; 
  20.             margin: 7px 7px 7px 7px;
  21.             background-color:gray;
  22.             text-align: center;
  23.             overflow:hidden;
  24.             z-index:4;
  25.         }
  26.  
  27.     <div class="Pane1">
  28.         <img class="PaneImage" src="something.jpg" id="imageId1"/>
  29.     </div>
  30.  
  31.  
I've been using Firefox 2.0.0 and IE 6.0

Thanks in advance for any ideas :)
Mar 2 '08 #1
3 1700
drhowarddrfine
7,435 Expert 4TB
It's due to your z-index putting the image in front of the div so when it overflows, the div doesn't cover it up.

Be careful because IE handles overflow incorrectly and expands elements to contain floats, which is an IE only bug.

I would rethink your positioning in your CSS. You are using text-align, absolute positioning and floats all on the same element. Some are canceling the other out. Generally I only use one of them on any element. Sometimes two.
Mar 3 '08 #2
mrrolf
3
Thanks Drhowarddrfine. I tried to change the z-index but it wasn't giving me the desired effects. Instead I added a clip attribute to the parenting object. That seems to work just fine. Although it sucks I have to hard-code the values in the rect(), it's something I can live with. Thanks for the help!


Expand|Select|Wrap|Line Numbers
  1.    clip: rect(auto, 188px, 500px , auto);
  2.  
Mar 3 '08 #3
drhowarddrfine
7,435 Expert 4TB
I had just removed the z-index, rather than changing the values, and it fixed the problem. Perhaps you set it to a value that still caused the overlaping.
Mar 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Halldor Isak Gylfason | last post by:
I am faced with the task of porting a client application to a web architecture platform, e.g. to make it browser based. The technology I used was J2EE, e.g. servlets/JSP pages and HTML/javascript....
16
by: Christopher Benson-Manica | last post by:
Can anyone tell me which browsers implement Javascript 1.3? Specifically, which browsers will handle the identity operator (===) correctly? I ask because jslint suggests using it, but I don't want...
8
by: bradwiseathome | last post by:
I have code that works in IE 6 but does not work in FireFox 1.0.2, how can I change it so it works in both browsers? <html> <head> <script language="JavaScript" type="text/JavaScript">...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: OwlHoot | last post by:
I am using Thomas Fuchs's amazing drag-and-drop JavaScript library available at: http://wiki.script.aculo.us/scriptaculous/show/DragAndDrop to allow the user to select a subset of items listed...
7
by: raylaur | last post by:
I'm using a javascript "slide" function to move a <div> layer in 10 pixel increments from one location on a page to another. The layer contains a GIF image. It's basically a side panel that flies out...
3
by: Cartoper | last post by:
I would like to design a web page as follows: There is a box (box A) with some things in it that the user can click on. When an item is clicked, another box (box B) moves in from the right side...
9
by: mevryck | last post by:
Greetings I have a huge Javascript with inclusion of external scripts and all. I got this by doing a XSLT . Now I have the contents in a Javascript variable, but I'm not able to update the...
3
by: happyse27 | last post by:
Hi All, I am creating the perl script using html form(with embedded javascript inside). When using this html form with javascript alone, it works where the form validation will pop up...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.