2011-10-27 2 views
2

두 개의 DIV가 서로 쌓여 있으며 세 번째 DIV로 묶여 있습니다. 그런 다음 스택 된 DIV 아래에 "빨간색"DIV가 있습니다.IE에서 스택 된 DIV의 공백을 제거하려면 어떻게합니까?

Chrome에서 DIV가 올바르게 표시됩니다. IE6과 IE7에서는 누적 된 DIV와 빨간색 DIV 사이에 공백이 있습니다.

enter image description here

당신이 당신의 CSS에서 top: -58
<style> 
div.imgbox { 
    position:relative; 
    top:0; 
    left:0; 
    bottom:0; 
    right:0; 
    width:103px; 
    height:58px; 
} 

div.imgthumb { 
    position:relative; 
    background:#000000; 
    z-index:3; 
    width:103px; 
    height:58px; 
} 

div.imgplay { 
    position:relative; 
    top:-58; 
    color:red; 
    z-index:4; 
} 

div.imgplay a { 
    width:103px; 
    height:58px; 
    display:block; 
} 

div.imgplay img { 
    width:25px; 
    height:25px; 
} 
</style> 

<div class="imgbox"> 
<div class="imgthumb"></div> 
<div class="imgplay"><a href="#"><img src="http://freetvpower.com/attachments/Image/play_up.gif" /></a></div> 
</div> 
<div style="width:103px; height:58px; background-color:red;"></div> 
+0

마녀 버전 즉 테스트를 마쳤습니까? 나는 ie9를 가지고 잘 작동하는 것 같다 ... – CrisDeBlonde

+0

ie6과 ie7을 사용했다. – supercoolville

답변

4

, 당신은 'PX'접미사를 생략 한 - 그것이 있어야 :

div.imgplay { 
    position:relative; 
    top:-58px; 
    color:red; 
    z-index:4; 
} 

다음 솔루션은 position:relative 왕겨를 제거한다 밀 곧장으로 가야합니다.

http://jsfiddle.net/4UEdJ/ (Internet Explorer에서 테스트하지 않음 : $)

+0

'margin-top : -58px'를 사용하는 것이 더 좋은 방법 일 수있다. – Benjie

+0

"px"를 추가해도 작동하지 않으며 "margin-top"을 추가하면 링크 내부가 사라집니다. – supercoolville

+0

Internet Explorer가 없기 때문에 테스트 할 수 없지만이 작업은 http://jsfiddle.net/4UEdJ/? – Benjie

0

'position : relative;'가 필요합니다. 마지막 div에서 상단의 위치를 ​​변경하려면 즉,

<div style="width:103px; height:58px; top:-58px; background-color:red; position: relative;"></div> 
+0

아 - 그럼 파이어 폭스에서 깨뜨린거야;) – Anthony

관련 문제