473,806 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving Div with javascript isn't respecting overflow

3 New Member
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 1721
drhowarddrfine
7,435 Recognized Expert Expert
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 New Member
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 Recognized Expert Expert
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
1816
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. The application I'm talking about is displaying data from database in grids, roughly speaking from 3 tables, that have parent-child relationship between them, and when you click on a row in a parent grid the content in the child grid should...
16
1732
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 to get too cutting edge. -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
8
1834
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"> function AttributeSelected() { var selectVal = document.forms.elements.options;
136
9468
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
1
2412
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 in one box by dragging them to another and sort them in the latter, and it works a treat. However, I'd now like to add a couple of buttons, "<<" and ">>" between
7
2401
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 when you click a button. The button is an invisible GIF with an anchor that calls slide() onClick. The animation works fine in IE but in Firefox I'm getting a series of afterimages as the function moves the layer to the goal. The image is painted...
3
3295
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 of box A. I don't want box B to exist outside of A, simply start on the right side and then cover up all of B. I am going to be targetting Firefox 2.x only, well if it works in IE7 and Safari 3, great, but the kiosk is going to be running...
9
4040
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 element with the javascript contents. But when viewed as a seperate HTML file with the below contents I'm able to see the milonic menu http://www.milonic.com . <div>
3
3912
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 javascript windows to say the field is not keyed into properly. However, when i convert this html(with javascript inside) into perl script, the perl script did not validate when i keyed incorrect data in the form and it straight away executed perl script...
0
10369
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.