473,405 Members | 2,349 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,405 software developers and data experts.

Positioning weirdness

I've run into a weird problem and i'm not sure if it's a bug in the
browsers or if this is part of the standard.

A simple example:

#x {
min-width: 600px;
}

#y {
position:absolute; top:0px; right:0px; margin-left:600px;
}

<div id="x">This is a test</div>
<div id="y">This is the main area</div>

This works great, and does what I expect, namely stopping the right div
from moving over the minimum size area of the left div.

However, if I add "width: 215px" to #y, then the margin-left attribute
appears to be ignored. It does this in both IE and Firebird.

Can anyone shed some light on this, and perhaps offer a solution?
Jul 20 '05 #1
9 1754
Erik Funkenbusch wrote:
#x {
min-width: 600px;
}

#y {
position:absolute; top:0px; right:0px; margin-left:600px;
}

<div id="x">This is a test</div>
<div id="y">This is the main area</div>

However, if I add "width: 215px" to #y, then the margin-left attribute
appears to be ignored. It does this in both IE and Firebird.


URL for the test case? What exactly you're trying to achieve?

If you're using position: absolute, you should use top, left, right,
bottom, width and height only, IMHO. It works better.

--
Mikko

Jul 20 '05 #2
On Tue, 16 Sep 2003 10:06:40 +0200, Rijk van Geijtenbeek wrote:
On Mon, 15 Sep 2003 19:21:02 -0500, Erik Funkenbusch
<er**@despam-funkenbusch.com> wrote:
I've run into a weird problem and i'm not sure if it's a bug in the
browsers or if this is part of the standard.

A simple example:

#x {
min-width: 600px;
}

#y {
position:absolute; top:0px; right:0px; margin-left:600px;
}

<div id="x">This is a test</div>
<div id="y">This is the main area</div>

This works great, and does what I expect, namely stopping the right div
from moving over the minimum size area of the left div.

However, if I add "width: 215px" to #y, then the margin-left attribute
appears to be ignored. It does this in both IE and Firebird.

Can anyone shed some light on this, and perhaps offer a solution?


Your div#y becomes over-constrained. Think about: you've fixed the 'right'
edge and the 'witdh' of the box. Now the left edge follows automatically,
or either 'width' or 'right' have to be ignored. According to the rules,
'margin' is the value that should adapt in such a case.


I'm not sure how it's over-constrained. It works fine with an auto-width,
even if I make the text in div#y larger than the width i'm specifying.

I'm trying to achieve the same effect that you can see on
www.csszengarden.com. if you resize the window, the navbar on the right
stays tacked to the right side of the browser until it reaches the
margin-left specified, in which case it extends off to the right and scroll
bars are added to the viewport to scroll over to it.

So, in effect, I want a "liquid" content area that has a min-width and a
right-side nav panel that's fixed to the right side of the viewport but
doesn't resize over the content area. ie it stops at the right side of the
content area when the content reaches it's min-width.
Jul 20 '05 #3
On Tue, 16 Sep 2003 09:35:00 +0300, Mikko Rantalainen wrote:
Erik Funkenbusch wrote:
#x {
min-width: 600px;
}

#y {
position:absolute; top:0px; right:0px; margin-left:600px;
}

<div id="x">This is a test</div>
<div id="y">This is the main area</div>

However, if I add "width: 215px" to #y, then the margin-left attribute
appears to be ignored. It does this in both IE and Firebird.


URL for the test case? What exactly you're trying to achieve?

If you're using position: absolute, you should use top, left, right,
bottom, width and height only, IMHO. It works better.


See my message in response to Rijk van Geijtenbeek.
Jul 20 '05 #4
On Tue, 16 Sep 2003 12:59:58 -0500, Erik Funkenbusch
<er**@despam-funkenbusch.com> wrote:

...
I'm not sure how it's over-constrained. It works fine with an
auto-width, even if I make the text in div#y larger than the width i'm
specifying.


Say you have an available width of 600 pixels. You tell the browser to
make a (border- and paddingless) DIV exactly 300 pixels wide, and fix the
right hand side at zero pixels from the right hand edge. Now consider that
margin+padding+border+contentwidth must equal available width. Now how can
the browser honor a left-margin of anything else but 300 pixels?

--
Rijk van Geijtenbeek
Jul 20 '05 #5
On Tue, 16 Sep 2003 20:43:17 -0500, Erik Funkenbusch
<er**@despam-funkenbusch.com> wrote:

...
That doesn't seem to explain why auto width honors the margin-left
attribute, and creates scroll bars if you resize the window to below the
size if the margin creating a larger area than you can see.

All i'm asking is for the same behavior if the width of div#y is auto or
fixed. Why would it ignore margin-left: with fixed width but not auto?
Because it can not honor everything at the same time.
Also, if I don't use positiong, and set the content width larger than the
window size, it'll create scrollbars as well. So your comment about the
margin+padding+border+contentwidth must equal available width doesn't
seem to fit with my understanding of things. Can you explain this?


Sure. You get a negative margin in that case. Please try reading the
relevant chapter in the CSS2 spec if you don't believe me ;)

http://www.w3.org/TR/CSS2/box.html
http://www.w3.org/TR/CSS2/visudet.ht...hs_and_margins

As for the specific effect you want, I'd suggest dissecting the stylesheet
used for it on www.csszengarden.com.

--
Rijk van Geijtenbeek
Jul 20 '05 #6
On Wed, 17 Sep 2003 17:19:38 +0200, Rijk van Geijtenbeek wrote:
On Tue, 16 Sep 2003 20:43:17 -0500, Erik Funkenbusch
<er**@despam-funkenbusch.com> wrote:

..
That doesn't seem to explain why auto width honors the margin-left
attribute, and creates scroll bars if you resize the window to below the
size if the margin creating a larger area than you can see.

All i'm asking is for the same behavior if the width of div#y is auto or
fixed. Why would it ignore margin-left: with fixed width but not auto?


Because it can not honor everything at the same time.
Also, if I don't use positiong, and set the content width larger than the
window size, it'll create scrollbars as well. So your comment about the
margin+padding+border+contentwidth must equal available width doesn't
seem to fit with my understanding of things. Can you explain this?


Sure. You get a negative margin in that case. Please try reading the
relevant chapter in the CSS2 spec if you don't believe me ;)

http://www.w3.org/TR/CSS2/box.html
http://www.w3.org/TR/CSS2/visudet.ht...hs_and_margins

As for the specific effect you want, I'd suggest dissecting the stylesheet
used for it on www.csszengarden.com.


It's not that I didn't believe you, It's that I didn't understand it.

Thanks for the pointers.
Jul 20 '05 #7
On Wed, 17 Sep 2003 17:19:38 +0200, Rijk van Geijtenbeek wrote:
As for the specific effect you want, I'd suggest dissecting the stylesheet
used for it on www.csszengarden.com.


I have been doing that, which is where I got the margin-left: idea.

The links you provide though did lead me to a new idea, which was to set a
minimum width on a non-static parent container, which seems to work in
Firebird, but not in IE. I think the key I was missing was the
"containing-block" definition which the CSS spec provides.

Now, if I can figure out a workaround for IE...
Jul 20 '05 #8
On Wed, 17 Sep 2003 12:29:38 -0500, Erik Funkenbusch wrote:
On Wed, 17 Sep 2003 17:19:38 +0200, Rijk van Geijtenbeek wrote:
As for the specific effect you want, I'd suggest dissecting the stylesheet
used for it on www.csszengarden.com.


I have been doing that, which is where I got the margin-left: idea.

The links you provide though did lead me to a new idea, which was to set a
minimum width on a non-static parent container, which seems to work in
Firebird, but not in IE. I think the key I was missing was the
"containing-block" definition which the CSS spec provides.

Now, if I can figure out a workaround for IE...


Well, to answer my own questions. min-width: isn't supported on IE.
Therea are two workarounds though. One is to use a fixed width HR, IE
won't shrink the containing block below the width of the HR. The other is
to use a script from doxdesk.com call minmax.js.

I like the idea of making min-width: work, but I don't like using extra
javascript to work around bugs. The script solution makes the HTML
cleaner, but requires more stuff to download, increasing the time to
download the page. Decisions.. decisions...

If you could answer one more quesiton for me, I'd really appreciate it. I
notice that Firebird does collapose the containing block over the HR even
when it has a specific width, is that allowed by the standard?
Jul 20 '05 #9
On Wed, 17 Sep 2003 13:34:06 -0500, Erik Funkenbusch
<er**@despam-funkenbusch.com> wrote:

...
If you could answer one more question for me, I'd really appreciate it.
I notice that Firebird does collapse the containing block over the HR
even
when it has a specific width, is that allowed by the standard?


I can't answer that. HR is a rather special element, it is not well
defined in the HTML spec how it should fit into the block/inline/replaced
scheme, and neither does CSS say much about it. You can see it as an empty
block with just a border set, but that is just a possible interpretation.
I would avoid using HR in a standards based page ;) Just use DIV to mark
sections, and set borders on the DIV where the section delimiter should be
visible.

--
Rijk van Geijtenbeek
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
4
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
3
by: Jonah Bishop | last post by:
I have a strange problem that I'm hoping someone can help me with. I want a footer at the bottom of my simple HTML page to span the entire width of the page. I'm not using floats, columns or any...
14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
1
by: Charles Harrison Caudill | last post by:
with tables there is a clean and algorithmic way to organize things, but with css which is, once you get it working, much cleaner, I have to tweak and patch and hope and pray and curse before...
2
by: jcrouse | last post by:
In VB .Net is it possible to specify a location (x, y) for message boxes and the common dialog box class like you can do for windows forms? If so, how is this accomplished? Thank you, John
5
by: David Thielen | last post by:
Hi; I am creating png files in my ASP .NET app. When I am running under Windows 2003/IIS 6, the file is not given the security permissions it should have. It does not have any permission for...
6
by: Mark | last post by:
hi, i'm trying to position something in the top right corner of a container, but i can't seem to figure out how to get it working. here's the html <div class='thumb'><a href='image.jpg'><img...
1
by: rhino | last post by:
I've got some positioning problems that I can't figure out. Can anyone help? My website was working fine in IE7 and the current releases of Firefox and Opera so I had a look at it in IE6 and...
2
by: JYA | last post by:
Hi. I was writing an xmltv parser using python when I faced some weirdness that I couldn't explain. What I'm doing, is read an xml file, create another dom object and copy the element from...
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: 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
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...
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,...
0
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...

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.