Skip to main content

Bug Tracker

Side navigation

#7701 closed bug (invalid)

Opened December 04, 2010 07:44PM UTC

Closed December 04, 2010 11:08PM UTC

Last modified March 13, 2012 10:25PM UTC

reinit css value for "top,bottom,left,right"

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

if you applied a value for top and left on a element and later, if you want to positionned this element with bottom/right it doesnot work event if you give an empty,null,auto,undefined value to top and left value.

Attachments (0)
Change History (7)

Changed December 04, 2010 08:24PM UTC by jitter comment:1

owner: → anonymous
status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Please submit a valid reduced test case, which reproduces the issue you are experiencing, on http://jsfiddle.net. So that we can investigate this issue further.


How to report bugs

Changed December 04, 2010 09:24PM UTC by anonymous comment:2

status: pendingnew

You can see this bug here:

http://jsfiddle.net/KQYz6/1/

Changed December 04, 2010 11:08PM UTC by danheberden comment:3

_comment0: Thanks for taking the time to investigate this particular case. However, it isn't a bug, but rather - an issue of positioning in the browser. \ \ Its similar to a css declaration, where if you have top and left defined along with right and bottom, it's hard to the browser to know quite what you mean. Particularly if the element has a fixed width. \ \ So in the case of your example, if you think of it from the browser's perspective, how can it position it bottom/right when it's already top/left? \ \ First, relinquish control over top/left. Something like \ \ \ {{{ \ .css({top: 'auto', left: 'auto' }) \ }}} \ \ \ will let you use the bottom/right stuff. \ \ One note, though, these kind of animations can be a pain. Youll have to (just as you would with css) compensate for the bottom/right if you had it positioned top/left - e.g. the left of a 100px box in a 600px container is 100px, where the right is 400px. Just a head ups if you run into jumpy animations :D \ \ Here's your demo, but with the top/left set to auto: \ \ [http://jsfiddle.net/danheberden/9t9FZ/]1291504164387716
resolution: → invalid
status: newclosed

Thanks for taking the time to investigate this particular case. However, it isn't a bug, but rather - an issue of positioning in the browser.

Its similar to a css declaration, where if you have top and left defined along with right and bottom, it's hard to the browser to know quite what you mean. Particularly if the element has a fixed width.

So in the case of your example, if you think of it from the browser's perspective, how can it position it bottom/right when it's already top/left?

First, relinquish control over top/left. Something like

.css({top: 'auto', left: 'auto' })

will let you use the bottom/right stuff.

One note, though, these kind of animations can be a pain. Youll have to (just as you would with css) compensate for the bottom/right if you had it positioned top/left - e.g. the left of a 100px box in a 600px container is 100px, where the right is 400px. Just a heads up if you run into jumpy animations :D

Here's your demo, but with the top/left set to auto:

http://jsfiddle.net/danheberden/9t9FZ/

Changed December 05, 2010 10:32AM UTC by anonymous comment:4

Thanks for your reply.

I already tried : ".css({top: 'auto', left: 'auto' })" it doesnot work.

More over, the difference between positionning div element at the bottom right corner with top/left proprieties rather than bottom/right proprieties is when the user enlarge is browser window:

With bottom/right proprieties it's always at the bottom right corner, with top/left proprieties it doesnot.

It really be nice if jQuery could do this staff by removing css "top,bottom,left,right" proprieties before updating them.

Changed December 06, 2010 06:45AM UTC by danheberden comment:5

Did you see my example? Where positioning bottom/right works?

It would be cool if jquery reset these values, but then the cases of what if you only give a bottom param? Then for everybody ever setting top, right, bottom or left the element's dimensions have to be calculated, reset, stored, and that adds overhead for every possible call.

This is one of those cases where from a performance perspective, it makes much more sense (performance wise) to write your own function to handle that (assuming you're doing it more than once), that is, get the items dimensions, create new bottom/right values based of its current top/left with regards the dimensions of it's parent and then make your animation call.

Anyway, hope this explains it well :)

Changed January 28, 2011 05:30PM UTC by nicolas.albert@convertigo.com comment:6

In JQuery <= 1.4.2 you can clear a previously set style with ".css('key', 'value')" with ".css('key', null)".

In JQuery > 1.4.2 you need to use ".css('key', '')".

Tested for left, top, position, z-index, width, height !

Changed January 28, 2011 05:33PM UTC by nicolas.albert@convertigo.com comment:7

Replying to [comment:6 nicolas.albert@…]:

In JQuery > 1.4.2 you need to use ".css('key', '')".

I mean empty chain :

.css("key", "");