2013-01-13 29 views
0

所以,我很想忽略ie8,但在這種情況下,完成的應用程序將分佈在僅運行ie8的便攜式計算機上。我希望有人能夠提供幫助,因爲我已經用盡了知識來解決我自己的問題。ie8在顯示div時不會改變邊距

對於本站點,當您單擊頁面一側的「選項卡」時,屏幕左側會出現一個「托盤」。並且「標籤」應該向右移動「托盤」的深度。我在所有的webkit瀏覽器中都能很好地工作,但不是ie8。這是代碼。感謝您的任何意見,我還很早就接受了自我教育。

button2是div控股image2。 thumbnails2是「托盤」

 <script> 
    function showThumbnails2() { 
     document.getElementById('thumbnails2').style.display = "block"; 
     document.getElementById('button2').onclick = hideThumbnails2; 
     document.getElementById('image2').style["margin-left"] = "149px"; 
    } 
    function hideThumbnails2() { 
     document.getElementById('thumbnails2').style.display = "none"; 
     document.getElementById('button2').onclick = showThumbnails2; 
     document.getElementById('image2').style["margin-left"] = "0px"; 
    } 
    </script> 

和一些從文檔的身體......

<a onclick="showThumbnails2()" href="#" id="button2"><img src="images/PullButtonleft.png" alt="Click for Topics" width="20" height="100" style="clear:both;display:block; position:absolute; margin-top:334px; left:0px;" id="image2"></a> 

    <a onclick="showThumbnails2()" href="#" id="button2"><img src="images/PullButtonleft.png" alt="Click for Topics" width="20" height="100" style="clear:both;display:block; position:absolute; margin-top:334px; left:0px;" id="image2"></a> 

計算器一直在幫助我得到這個寶貴的遠,我希望我已經問及格式化這是正確的,再次感謝。

回答

0

而不是更改margin-left屬性,爲什麼不嘗試使用left: 150px而不是因爲您正在使用絕對定位?我無法訪問Windows機器,因此我無法測試您的margin-left問題,但更改left屬性應該可行。

document.getElementById('image2').style.left = "149px"; 
+0

完美的工作! ie8將會是我的死亡,謝謝。 – jkuhns5