2009-09-20 1 views
14

WebKit에서 버그를 발견했습니다. outerWidth (true)를 포함하고 jQuery에서 outerHeight (true)로 가정합니다.WebKit (또는 jQuery)에서 버그를 발견했는데 다른 사람이 확인할 수 있습니까?

Safari와 Chrome을 제외한 모든 브라우저에서 세 번째 상자는 200입니다. Safari와 Chrome에서는 화면의 너비와 거의 같습니다. 당신은 테스트 할 수 있습니다

여기에 자신을위한 inline image not found. http://x3non.com/image/alec/147/outerWidth%20true%20fail.png

:

클릭 here 내 결과를 볼 수 그것은을 찾는 버그 아니다

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
    <style type="text/css"> 
    input { 
     width: 50%; 
     height: 1em; 
     font-size: 1em; 
    } 
#testBox {margin-left:100px;width:100px;} 
#testBox2 {padding-left:100px;width:100px;} 
#testBox3 {border-left:100px black solid;width:100px;} 
    </style> 
    <script type="text/javascript"> 
    function init(){ 
     $('#w1').val($('#testBox').width()); 
     $('#ow1').val($('#testBox').outerWidth()); 
     $('#owt1').val($('#testBox').outerWidth(true)); 
     $('#w2').val($('#testBox2').width()); 
     $('#ow2').val($('#testBox2').outerWidth()); 
     $('#owt2').val($('#testBox2').outerWidth(true)); 
     $('#w3').val($('#testBox3').width()); 
     $('#ow3').val($('#testBox3').outerWidth()); 
     $('#owt3').val($('#testBox3').outerWidth(true)); 
    } 
    $(document).ready(function(){ 
     init(); 

     $(window).resize(function(){ 
     init(); 
     }); 
    }); 
    </script> 

</head> 
<body> 
<div id="testBox">test</div> 
    <p>width() <input type="text" id="w1" /></p> 
    <p>outerWidth() <input type="text" id="ow1" /></p> 
    <p>outerWidth(true) <input type="text" id="owt1" /></p> 

<div id="testBox2">test2</div> 
    <p>width() <input type="text" id="w2" /></p> 
    <p>outerWidth() <input type="text" id="ow2" /></p> 
    <p>outerWidth(true) <input type="text" id="owt2" /></p> 

<div id="testBox3">test3</div> 
    <p>width() <input type="text" id="w3" /></p> 
    <p>outerWidth() <input type="text" id="ow3" /></p> 
    <p>outerWidth(true) <input type="text" id="owt3" /></p> 
</body> 
</html> 

답변

11

Chrome의 DOM 검사자가 이것이 웹킷 문제임을 확인합니다. margin-right을 무시하려고해도 div에 큰 오른쪽 여백이 생깁니다. 한계를 정확하게 계산하도록 강제하는 몇 가지 사항은 float: leftdisplay: inline-block입니다. 또한 div를 다른 크기의 div에 넣으면 그 outerWidth(true)이 포함 된 div의 을 제공합니다. 이는 유용한 실제 해결 방법이 될 수 있습니다. margin: 0; padding: 0; width: XXX으로 div로 묶으십시오.

1

:이 테스트 파일을 사용

http://ramblingwood.com/sandbox/webkit-bug/test.html 바깥 쪽 너비. Webkit은 실제로 div에 큰 오른쪽 여백을 부여합니다. 오른쪽 여백이 오른쪽 가장자리까지 (거의) 확장되기 때문에 더 큰 외부 너비를 얻을 수 있습니다.

"올바른"방법으로 렌더링 할 수 있는지 확실하지 않지만 오른쪽 여백이 확장되지 않아야한다는 사양이있는 경우 WebKit의 버그 일 수 있습니다.

+1

에서 testet, 그것은 크로스 브라우저 코드를 작성할 때 짜증나 정말 fricken입니다. –

0

나는 이것을 확인할 수도 있습니다.

웹킷은이 작업을 수행하는 것이 정말 이상한이며, 사람이 좋은 생각이라고 생각 왜 내가 상상할 수 없다.

Chrome 4에서 수정했는지 궁금합니다.

1

내 경험으로도이 사실을 확인할 수 있습니다. Webkit 버그이며 수정해야합니다. 당신은 크기가이 버그를 수정하여 입력 필드에 한 말을 설정하면

1

는 - 어떤 경우에 크롬과 사파리

관련 문제