【问题标题】:Cloudinary jQuery Add HTML Element to ImageCloudinary jQuery 将 HTML 元素添加到图像
【发布时间】:2015-06-20 20:19:25
【问题描述】:

我正在使用 Cloudinary 进行图像管理。我正在使用以下方式调用图像:

$.cloudinary.image(data.result.public_id, {
    format: "jpg", width: 300, height: 200, crop: "fill"
})

有谁知道我如何在这张图片中添加一个 html 元素,例如style="max-width: 100%"?我似乎在他们的文档中找不到它。

【问题讨论】:

    标签: javascript jquery cloudinary


    【解决方案1】:

    虽然这可能与您的方法略有不同,但从功能上讲,它可以通过在图像元素上添加自定义类然后从那里更改样式来做同样的事情。

    在你的例子中:

    js:

    $.cloudinary.image(data.result.public_id, {
        format: "jpg", width: 300, height: 200, crop: "fill", class: "your-custom-class"
    });
    

    css

    .your-custom-class {
      max-width: 100%;
    }
    

    文档在这里:http://cloudinary.com/documentation/jquery_image_manipulation 检查延迟加载和动态转换部分。

    【讨论】:

      【解决方案2】:

      也可以直接设置style属性,例如:

      $.cloudinary.image(data.result.public_id, {format: "jpg", width: 300, height: 200, crop: "fill", style: "max-width:100%" })
      

      【讨论】:

        猜你喜欢
        • 2021-01-04
        • 2013-08-11
        • 1970-01-01
        • 1970-01-01
        • 2011-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-01
        相关资源
        最近更新 更多