我想开始讨论使用jQuery调整图像大小.
这是我的贡献:但我认为我远离解决方案.种植怎么样?谁能帮我?
$(document).ready(function() {
$('.story-small img').each(function() {
var maxWidth = 100; // Max width for the image
var maxHeight = 100; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
ratio = maxWidth / width; // get ratio for scaling image
$(this).css("width", maxWidth); // …
Run Code Online (Sandbox Code Playgroud)