zoukankan      html  css  js  c++  java
  • js,jquery缩小加载的图片202005131907

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title></title>
            <style type="text/css">
                
                div{
                    position: absolute;
                    min-width: 600px;
                    min-height: 600px;
                    width: 100%; 
                    height: 100%;
                    border: 1px solid black;
                }
                
                a{
                    position: absolute;
                    z-index: 10;
                }
                
                .td{
                    /* 100%;
                    height: auto;*/
                    /*border: 1px solid lime;*/
                }
                
                .tr{
                    
                }
                
                .table{
                    /*border-spacing:0px 100px;
                    border: 1px solid black;*/
                }
                
                img{
                    
                }
                
            </style>
            <script type="text/javascript" src="js/jquery-1.12.4.js" ></script>
        </head>
        <body>
            <!--<div style="">
                <a href="#" class="clazz1">测试1</a>
            </div>-->
            
            <!--<span style="position: absolute; border: 1px solid lime;  100%; height: 100%;">
                
            </span>
            
            <span style="position: absolute; border: 1px solid lime;  100%; height: 100%;">
                
            </span>-->
            
            <!--<a href="#" style="top: 50px;">测试2</a>-->
            
            <!--<table class="table">
                <tr class="tr">
                    <td class="td">123</td>
                    <td class="td">456</td>
                </tr>
                <tr class="tr">
                    <td class="td">789</td>
                    <td class="td">101</td>
                </tr>
                <tr class="tr">
                    <td class="td">202</td>
                    <td class="td">303</td>
                </tr>
            </table>-->
                
             <img src="http://10.127.32.132:8080/topicSolutions/convertedPicFile/0.jpg">
                
            <script type="text/javascript">    
                
                var maxWidth = 100;
                var maxHeight = 200;
                
                zoomImage();
                
                function zoomImage(){
                    $("img").each(function(){
                        var url = $(this).attr("src");
                        $(this).load(function(){
                            var w = $(this).css("width").substring(0, $(this).css("width").length - 2);
                            var h = $(this).css("height").substring(0, $(this).css("height").length - 2);
                            if(w > 0 && h > 0){
                                var rate = 0;
                                var width = 0;
                                var height = 0;
                                if(w > maxWidth){
                                    rate = w / maxWidth;
                                    w = maxWidth;
                                    h = h / rate;
                                }
                                if(h > maxHeight){
                                    rate = h / maxHeight;
                                    h = maxHeight;
                                    w = w / rate;
                                }
                                width = w;
                                height = h;
                                $(this).css({
                                    "width": width + "px",
                                    "height": height + "px"
                                });
                                $(this).parent().css({
                                 "width": width + "px",
                                 "height": height + "px"
                                 });
                            }
                        });
                    });
                }
                
                /*var text = "gxcfgd[IMAGE_BEGIN]D:/Resume/TopicSolutions/Picture/0.wmf[IMAGE_END]cgfffb[IMAGE_BEGIN]D:/Resume/TopicSolutions/Picture/1992.wmf[IMAGE_END]gcf1524fg";
                var reg = /[IMAGE_BEGIN]([^[I])+[IMAGE_END]/g;
                alert(text.match(reg));
                text.lastIndexOf()*/
                /*$(".clazz1").on("click", function(){
                    alert(1);
                });*/
                
            </script>
    
        </body>
    </html>

    效果图

  • 相关阅读:
    java9
    java8
    java7
    java6
    java5
    java4
    java-list-分组
    Termux中安装gcc-7/gfortran-7实操过程,安装成功可以编译Fortran,c/c++
    安卓手机牛逼软件Termux中安装Archlinux,安装Jdk
    c++语言的组合类的使用,用组合类的方法计算两点间距离。
  • 原文地址:https://www.cnblogs.com/JimmySeraph/p/12884321.html
Copyright © 2011-2022 走看看