Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

User-contributed notes

ID:
#2
Date:
Sat, 26 Apr 2008 07:24:10 GMT
Contributed by:
haaiee
Status:
This note has not yet been confirmed for accuracy and relevance.

If you combine a "right", a "left" and a "height" declaration together with an image, the effect is different in firefox than in other browsers (opera,ie).

firefox honors the calculated width, while the other browsers honor the aspect ratio of the image.

in the following code I use a 10x10px image called green.png.

---- html file ----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div id='y' style='position:absolute;width:50%;height:100px;border:1px solid red;overflow:hidden;'>
<img src='green.png' id='x' style='position:absolute;left:50px;right:50px;height:50px;' />
</div>
</body>
</html>
---- end html file ----

is there a way to get all browsers to behave like ff?

ID:
#1
Date:
Sat, 26 Apr 2008 06:30:09 GMT
Contributed by:
haaiee
Status:
This note has not yet been confirmed for accuracy and relevance.

You say "If both right and left have a value other than auto, the offset is over-constrained. If the direction property is ltr, right will be ignored."

This seems not to be true for firefox and opera:
---- html file ----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div id='y' style='position:absolute;width:50%;margin-left:auto;margin-right:auto;height:100px;border:1px solid red'>
<div id='x' style='position:absolute;left:50px;right:50px;height:50px;background-color:green;'>
x
</div>
</div>
</body>
</html>
---- end HTML file ----
clearly results in both left and right set to 50px

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters