我正在使用 Cloudinary 进行图像管理。我使用以下方式调用图像:
$.cloudinary.image(data.result.public_id, {
format: "jpg", width: 300, height: 200, crop: "fill"
})
有谁知道如何向该图像添加 html 元素,例如 style="max-width: 100%"
?我似乎在他们的文档中找不到它。
最佳答案
虽然这可能与您的方法略有不同,但从功能上讲,它可以通过在图像元素上添加自定义类然后从那里更改样式来完成相同的操作。
在您的示例中:
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 检查延迟加载和动态转换部分。
关于javascript - Cloudinary jQuery 将 HTML 元素添加到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29640619/