Closed Bug 298052 Opened 19 years ago Closed 18 years ago

when i use position:relative in CSS 'top' and 'bottom' doesnt work with %

Categories

(Core :: Layout: Positioned, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 260348

People

(Reporter: mike.dd, Unassigned)

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

#rd {
  position:relative;
  top:-50%;
  left:-50%;
  margin:0px;
  padding:0px;
}


Reproducible: Always

Steps to Reproduce:
1.relative position tested with 'table' and 'div'
2.
3.

Actual Results:  
'left','right' : work perfect
'top','bottom' : have no effect
Please attach a testcase with the "Create a New Attachment" link.
Also please try it out with a latest nightly trunk build, which you can find here:
http://ftp.scarlet.be/pub/mozilla.org/firefox/nightly/latest-trunk/
Assignee: nobody → dbaron
Component: View Source → Style System (CSS)
Product: Firefox → Core
QA Contact: view.source → ian
Version: unspecified → 1.0 Branch
First of all, with 'position: relative', only one of top and bottom will work:

http://www.w3.org/TR/CSS21/visuren.html#relative-positioning

Second, percentages on these properties are relative to the height of the
containing block, so if the containing block doesn't have a clearly defined
height, they're going to be ignored:

http://www.w3.org/TR/CSS21/visuren.html#position-props
Attached file html page + picture
1. table with red border should be centered.
    style:left works
    style:top doesnt 

2. when writing this demo i noticed that the pics are also not in place
   they are moved down.
Better test case comparing absolute positioning and relative positioning.
created clear testcase
By the way, I disagree with comment #2 that top %s should be ignored if height
not specified.  The height should still be computed.  Nothing at either of those
URLs in comment #2 say that %s should be ignored if height is not specified by rule.

Absolute positioning works perfectly even when height is not specified.
(BTW: thanks, hixie for your Data URI kitchen... makes creating testcases easy)
The only way to make this possibly work is to do all relative positioning shifts after the containing block is completely laid out (right now we do them as we lay out each line).

Confirming, but I really don't see the behavior here changing anytime soon.
Assignee: dbaron → nobody
Status: UNCONFIRMED → NEW
Component: Style System (CSS) → Layout: R & A Pos
Ever confirmed: true
OS: Windows XP → All
QA Contact: ian → layout.r-and-a-pos
Hardware: PC → All
Version: 1.0 Branch → Trunk
Several reasons (similar summary, similar description, similar D. Baron comment, etc.) lead me to believe that this bug is a duplicate of bug 260348. 

Resolving as DUPLICATE of bug 260348

*** This bug has been marked as a duplicate of 260348 ***
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: