Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pixel off in IE with position right or bottom and border

    It seems in some situations in IE, when you have a 0px right or bottom positioned element in a div with a border, a pixel of space can occur between the positioned element and the border. Has anyone encountered this before and found an easy solution for it? From my testing so far, this doesn't seem to occur in Firefox or in Safari. The version of IE I am using is 6.0.

    Example:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    	<title>Border Gap Test</title>
    	<script type="text/javascript">
    		var w = 200;
    		var h = 200;
    		function increaseDivSize() {
    			document.getElementById("div1").style.width = ++w + "px";
    			document.getElementById("div1").style.height = ++h + "px";
    		}
    	</script>
    </head>
    <body>
    	<input type="button" value="Increase Size" onclick="increaseDivSize()">
    	<p>Watch for a gap between the red box and the black bordered box as the black bordered box's size is increased.</p>
    	<div id="div1" style="position: relative; width: 200px; height: 200px; border: 5px solid black">
    		<div style="position: absolute; right: 0px; bottom: 0px; width: 50px; height: 75px; background: red">
    		</div>
    	</div>
    </body>
    </html>
    Last edited by Skotty; 08-22-2008 at 08:49 PM. Reason: left out beginning body tag in example ... oops

  • #2
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    This is a screen shot at 400&#37; on my PC using IE7.
    I can't see any gap.
    It shows on my IE6 simulator but only at certain magnifications.

    Look in the Sources program below. It has some IE6 items in it.

    This seems interesting

    Might be helpful.

    But why aren't you using CSS?

    Frank
    Attached Thumbnails Attached Thumbnails Pixel off in IE with position right or bottom and border-screenhunter_01-aug.-23-18.06.jpg  
    Last edited by effpeetee; 08-23-2008 at 06:44 PM.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't know how closely you looked at it, but the gap only occurs when the outer div is an odd width and/or height.

    Here is a further simplified version with no script:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    	<title>Border Gap Test</title>
    	<style type="text/css">
    		#div1 {
    			position: relative;
    			width: 200px;
    			height: 200px;
    			border: 5px solid black;
    			margin: 10px;
    			float: left;
    		}
    		#div2 {
    			position: relative;
    			width: 201px;
    			height: 201px;
    			border: 5px solid black;
    			margin: 10px;
    			float: left;
    		}
    		.inner {
    			position: absolute;
    			right: 0px;
    			bottom: 0px;
    			width: 50px;
    			height: 75px;
    			background-color: red;
    		}
    	</style>
    </head>
    <body>
    	<p>Look for a gap between the red box and the black border on the following two scenarios:</p>
    	<div id="div1">
    		200 x 200
    		<div class="inner">
    		</div>
    	</div>
    	<div id="div2">
    		201 x 201
    		<div class="inner">
    		</div>
    	</div>
    </body>
    </html>
    In this version, the box on the right side has a 1 pixel gap between the red box and the black border. The box on the left has no gap. The only difference is the outer div size.

  • #4
    New Coder
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Attached is a snapshot of how it looks on my screen.
    Attached Thumbnails Attached Thumbnails Pixel off in IE with position right or bottom and border-rb.png  

  • #5
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Scotty, just wondering: did you solve this problem? I have the same experience in IE.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Quote Originally Posted by Marcel- View Post
    Hi Scotty, just wondering: did you solve this problem? I have the same experience in IE.
    Make a new thread for you and explain the issues. Please post link to your page also, or at least all code (HTML +CSS). Here is another sample layout
    Last edited by abduraooft; 11-23-2008 at 03:29 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have not found a solution for this. I switched to using top/left positioning only. Not as convenient, but never is with IE.

  • #8
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Quote Originally Posted by Skotty View Post
    I have not found a solution for this. I switched to using top/left positioning only. Not as convenient, but never is with IE.
    I've been playing with it off and on for a day or two and I haven't figured it out either. We need the bughunter to figure out what's happening.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #9
    Regular Coder
    Join Date
    Apr 2008
    Location
    Manila, Philippines
    Posts
    263
    Thanks
    3
    Thanked 12 Times in 12 Posts
    check for this kind of invalid styles..
    Code:
    right: 0px; bottom: 0px;
    if you clear those.. maybe.. maybe... it'll fix your thing...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •