zoukankan      html  css  js  c++  java
  • 图片自适应不变形

    <script type="text/javascript">
    function ResizeImage(_image, max_width, max_height) {
    //var max_width = 300;
    //var max_height = 300;
    var _width = _image.width;
    var _height = _image.height;
    var width_ratio = _width / max_width;
    var height_ratio = _height / max_height;
    //alert("Width ratio:" + _width + ", Height Ratio:" + _height);

    if ( width_ratio >= height_ratio && _image.width > max_width) {
    _image.width = max_width;
    }
    else if (height_ratio > width_ratio && _image.height > max_height) {
    _image.height = max_height;
    }
    }
    </script>


    --------------------------方法二--------------------------------------

    HTML Image Auto Resize, HTML图片大小自动调整


    .ImageStyle {
    max-height:300px;
    max-300px;
    expression( (this.width > 300 && this.width > this.height) ? '300px': this.width+'px');
    height:expression( (this.height > 300 && this.height > this.width) ? '300px': this.height+'px');
    border: 0px;
    vertical-align: middle;
    }

  • 相关阅读:
    Linux:Day45(下)
    Linux:Day45(上)
    Linux:Day44(下)
    彻底理解JDK异步
    Ribbon是什么?
    RocketMQ学习笔记(一)eclipse版的quickstart
    线性表的遍历
    八皇后问题
    汉诺塔
    servlet的url-pattern规则
  • 原文地址:https://www.cnblogs.com/hupan508/p/4377242.html
Copyright © 2011-2022 走看看