ie6绝对定位BUG

在IE6中,当父级的宽高值为奇数时,子级绝对定位后总是差1像索,最好的解决方法就是尽量去设置宽高值为偶数,实在想解决,那就用css hack吧,,,_right:-1px ; bottom:-1px ....下例就是最好的证明,用了个JS去检测,IE6以上及标准浏览器必须得弹出 199 ,而只有IE6这个奇葩,竟然给来一个 198 ,晕啊。。。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#div1{299px;height:299px;background:gray;position:absolute;}
#div2{100px;height:100px;background:purple;position:absolute;right:0;bottom:0;/*_right:-1px;_bottom:-1px;*/}
</style>
<script type="text/javascript">
window.onload=function(){
	var oDiv2=document.getElementById('div2');
	
	oDiv2.style.right=0;
	alert(oDiv2.offsetLeft);
};
</script>
</head>
<body>
<div id="div1">
	<div id="div2"></div>
</div>
</body>
</html>

  

原文地址:https://www.cnblogs.com/hejia/p/2911149.html