2011-12-10 1 views
0

私はいくつかの大きな画像を持っていると仮定して、私は98 * 98 divを持ち、画像の中央部分をサムネイルとして表示したい、つまり、横幅と縦の中心幅* 98。私は次のPHPとHTMLコードを持っています。IE8で背景の一部を表示するには?

<?php list($width, $height) = getimagesize($thumbpath); 
if ($width > $height) { 
    $heightnew = 98; 
    $widthnew = 98 * $width/$height; 
} else { 
    $widthnew = 98; 
    $heightnew = 98 * $height/$width; 
} 
$thumbcss = ' style="background: url(\'' . $thumbpath . '\') no-repeat;' . 
      ' background-size: ' . $widthnew . 'px ' . $heightnew . 'px;' . 
      ' -moz-background-size: ' . $widthnew . 'px ' . $heightnew . 'px;' . 
      ' background-position: 50% 50%;'; 
echo '<div class="thumb"' . $thumbcss . '></div>';?> 

IE8以外のすべての先進的なブラウザで問題なく動作します。次に、私はCSSに以下を追加しようとしています:filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' . $thumbpath . '\', sizingMethod=\'scale\'); -ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' . $thumbpath . '\', sizingMethod=\'scale\');しかし、それはスケールされた中心の代わりに画像全体を拡大縮小することです。

対応方法はありますか__ IE8?

答えて

0

その画像のdiv背景を指定します。background:url(pathtoimage.ext)no-repeat center;

+0

私が望むものではありません。 – DrXCheng

関連する問題