2012-04-24 84 views
2

我想把輸入的圖標放在右邊,使它像組合一樣。我必須使用相對位置,因爲它必須是完整的代碼。我會寫一個jQuery插件並在任何地方使用它。IE9位置相對,負邊距

這是我的代碼。 Firefox和Chrome顯示正確,但IE-9有問題。如果我做圖標的margintop -15px,它會有點底部,如果我這樣做了-16px,它會進入輸入的頂部。

而且你可以在這裏看到它http://mrp.brove.net/explorer_relative.php

我怎樣才能解決這個問題?

<!DOCTYPE HTL> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8"> 
<meta name="robots" content="noindex, nofollow"> 
<meta name="googlebot" content="noindex"> 
<meta http-equiv="cache-control" content="no-cache"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
</head> 

<body> 
<div style="width:50%; position:relative; top:0; left:0; height:0; background-color:#ccc;"> 
    <input class="rounded" type="text" style="width:100%;"> 
    <img src="images/combo_sec.png" style="position:relative; z-index:2; float:right; margin-top:-16px; padding-right:5px;" /> 
</div> 
</body> 
</html> 

回答

2

你爲什麼不使用top:-value; 我認爲這將對你有用

,如果你想使用margin-top只能用這個IE9

margin-top/*\**/:-16px\9; 和其他瀏覽器如u給了。

可能會幫助你。

+0

我不使用頂部。因爲當我使用它的空間(圖標的空間)正在查看輸入的底部。所以我不能把一個新的元素靠近輸入的底部。 – 2012-04-24 12:13:10

+0

這是一種什麼樣的巫術?!? 'margin-top/* \ ** /: - 16px \ 9;'爲我工作! @你可以解釋一下嗎? – Kovah 2015-09-18 11:53:28