JQuery调整图像插件错误 [英] JQuery Resize image plugin error

查看:86
本文介绍了JQuery调整图像插件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现一个基于容器调整图像大小的简单插件。
问题是,我不明白为什么当我把它放在容器里时它没有调整我的图像大小

Im trying to implement a simple plugin that resize image based on a container. The problem is , I don't understand why it's not resizing my image when I placed it inside a container

这是一个简单的插件演示页面i'我试图复制

This is the simple plugin demo page i'm trying to replicate

https://dl.dropboxusercontent.com/u/6983010/wserv/imgLiquid/examples/imgLiquid.html

这是我的代码

<html>
<head>
<link rel="stylesheet" href="css/float.css">
<script type = "text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type = "text/javascript" src ="https://raw.github.com/karacas/imgLiquid/master/src/js/imgLiquid-min.js"></script>

<script type="text/javascript">
$(document).ready(function () {
    $(".imgLiquidFill").imgLiquid({fill:true, fadeInTime:500});
    $(".imgLiquidNoFill").imgLiquid({fill:false});
});
</script>


</head>
<body>

<div class="container" >
<img src="Creek.jpg"/></div>
</div>
</body>
</html>

我的CSS

.container {height: 440px;  width: 950px; background:#FFFFFF}


推荐答案

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Image</title>

    <style>
        .container{
            background-color:#f7f7f7;
            border:2px solid #ccc;
            margin:10px;
            display:inline-block;
        }
        .imgLiquid {
            display:block;
            overflow: hidden;
            background:transparent url('http://www.lotienes.com/imagenes/loading.gif') no-repeat center center;
        }
        .imgLiquid img{
            visibility:hidden;
        }
    </style>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
        type="text/javascript"></script>
    <script type="text/javascript"
        src="https://raw.github.com/karacas/imgLiquid/master/src/js/imgLiquid-min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".imgLiquidFill").imgLiquid({
                fill: true,
                fadeInTime:200,
                horizontalAlign: "center",
                verticalAlign: "top"
            });
        });
    </script>
</head>

<body>  
    <div class="container">
        <span class="imgLiquidFill imgLiquid" style="width:250px; height:250px;">
            <a href="/media/Woody.jpg"  target="_blank" title="test">
                <img alt="" src="/media/Woody.jpg"/>
            </a>
        </span>
    </div>
</body>
</html>

您更改代码而忘记定义 imgLiquidFill imgLiquid 对于使这个插件生效非常重要。在修改代码时,请确保您没有忘记任何内容。另一件事是你可以重命名该类,但要确保你也在脚本中重命名它以使其相同。

Your changing the codes and you forgot to define the imgLiquidFill and imgLiquid in the class which is very important to make this plugin effective. In modifying the codes make sure you didn't forgot anything. Another thing is you can rename the class but make sure you also rename it in the script to make it the same.

这篇关于JQuery调整图像插件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆