HTML5 css图片自动缩放

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML5 css图片自动缩放</title>
<style type="text/css">
.cont{ margin:0 auto; width:600px;}
.cont img{max-width: 100%!important; height: auto!important; width:expression(this.width > 600 ? "600px" : this.width)!important;}
</style>
</head>

<body>
<div class="cont">
  <p><img src="http://onestopweb.cn/product/0f2222f8345433be31a39b6cd0cac073.png"/></p>
  <p><img src="http://onestopweb.cn/product/100/0f2222f8345433be31a39b6cd0cac073.png"/></p>
</div>
</body>
</html>

 

效果图:
HTML5 css图片自动缩放_第1张图片
 

你可能感兴趣的:(html,max-width,图片自动缩放)