css樣式代碼
<style type="text/css">
img {max-width:500px; max-height:500px; scale:expression((this.offsetWidth > this.offsetHeight)?(this.style.width = this.offsetWidth >= 500 ? "500px" : "auto"):(this.style.height = this.offsetHeight >= 500 ? "500px" : "auto")); display:inline !important;}
</style>
樣本中是預設網頁所有的img的標籤中的圖片都會縮放,如果想讓特定的圖片縮放只要修改下前面的css名字,然後在網頁中調用就可以了
比如你要讓一張大圖片1024*768在一個100*100的容器裡顯示,那這個時候你就需要用到等圖片比縮放這個功能了!
<style type="text/css">
body{ margin:0; padding:0;}
img{
border:none;
max-width:100px; /* FF IE7 */
max-height:100px; /* FF IE7 */
_width:expression(this.width > 100 && this.width > this.height ? 100: auto); /* IE6 */
_height:expression(this.height > 100 ? 100 : auto); /* IE6 */
}
</style>
<body><img src="meinv.jpg" alt="" width=“1024” height=“768” /></body>
圖片等比列縮放的同時,你需要把圖片底部對齊,這時候可以用絕對位置實現!
圖片等比列縮放的同時,你需要把圖片水平置中,這時只要在父容器裡添加text-align:centre;即可!
圖片等比縮放且圖片底部對齊,這個時候還要水平置中的話,暫時能想到的是使用table!