5 replies [Last post]
garethrichardadams
Offline
newbie
Last seen: 17 years 35 weeks ago
Joined: 2004-09-20
Posts: 8
Points: 0

Hello all,

This is getting silly.

In my previous post I was having trouble lining up a child div with the bottom of a parent div. At the time I thought it was because I was seting sizes in ex/em. Turns out there's the same problem when using pixels...if the parent div is an odd number of pixels high.

Has anyone ever come across this before????

<html>
<head>
	<title>Untitled</title>
	
	<style>
body {
	background-color: black;
}
	
#mainmenu {
	position: absolute;
	left: 0px;
	top: 0px;
	
	width: 400px;
	height: 55px;
	
	background-color: white;
}

#test {
	position: absolute;
	left: 200px;
	bottom: 0px;
	
	height: 30px;
	
	background-color: blue;
}
	</style>
</head>

<body>
<div id="mainmenu">
	<div id="test">
		fdsfsdfsd
	</div>
</div>
</body>
</html>

moxie
Offline
Regular
Last seen: 17 years 34 weeks ago
Joined: 2004-09-23
Posts: 15
Points: 0

F**k Internet Explorer

Yes, that's strange.
But if you really want the maindiv to be an odd number of pixels, you could set the childdiv to bottom: -1px;

garethrichardadams
Offline
newbie
Last seen: 17 years 35 weeks ago
Joined: 2004-09-20
Posts: 8
Points: 0

F**k Internet Explorer

Yep - then it looks wrong in Mozilla, Opera, Netscape etc.

I don't understand how Microsoft created a rounding bug in something that uses pixels. That takes a special kind of incomptence...

Gareth

moxie
Offline
Regular
Last seen: 17 years 34 weeks ago
Joined: 2004-09-23
Posts: 15
Points: 0

F**k Internet Explorer

A little trick I use more and more, is the expressions within css, only readable by IE. I guess you've heard of it, but of not: It uses a proprietary thing called "expressions" which other browser can't read. So whenever I'm faced with some small pixeltroubles I don't care to investigate (because they are always found when testing IE), I use those expressions:

#div {
position:relative;
padding-left:20px;
padding-left:expression("10px"); // ignored by all browsers except IE
}

garethrichardadams
Offline
newbie
Last seen: 17 years 35 weeks ago
Joined: 2004-09-20
Posts: 8
Points: 0

F**k Internet Explorer

Hi,

Hmmm....I've heard of expressions but I never thought of putting a constant in there - thanks!

I don't like having to use workarounds but when such a simple thing like absolute positioning doesn't work properly I guess I don't have much choice.

Thanks again

Gareth

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 10 hours 18 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

F**k Internet Explorer

Hi garethrichardadams,

Firstly is the page in Standards mode?
Read up about doctypes via a search or from http://www.csscreator.com/links/linkspage.php

If you still need to target just IE you can use the Holly hack.

/* HH \*/ 
* HTML  #div{padding-left:10px;} 
/* end HH */

Hope that helps