jquery - 图像在旋转时未在 div 内调整大小

标签 jquery html css

这里我试图通过 jquery 旋转一个图像,但我面临的问题是,当我向左或向右旋转时,图像的某些部分超出了框架。它没有根据 css 调整大小属性(property);最大高度:100%;最大宽度:100%;并且此框架具有固定的宽度和自动高度。

$(function(){
$("#right").click(function(){
    $("#image").rotate({ animateTo:90 });
});

$("#left").click(function(){
    $("#image").rotate({ animateTo:-90 });
});
$("#reset").click(function(){
    $("#image").rotate({ animateTo:0 });
}); });

<button id="right">Right</button><button id="left">Left</button><button id="reset">Reset</button><div class="previewimg"><img src="http://twistedsifter.files.wordpress.com/2010/03/shipwreck-beach-zakynthos-vertical-panorama-greece.jpg" id="image"></div>

Jsfiddle

最佳答案

试试这个

$(function () {
    $("#right").click(function () {
        $("#image").rotate({
            animateTo: 90
        });
        $("#image").css("height", '268px');
    });
    $("#left").click(function () {
        $("#image").rotate({
            animateTo: -90
        });
        $("#image").css("height", '268px');
    });
    $("#reset").click(function () {
        $("#image").rotate({
            animateTo: 0
        });
        $("#image").css("height", '100%');
    });
});

关于jquery - 图像在旋转时未在 div 内调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18013330/

相关文章:

jquery - 如何在彼此相邻的不同 div 中实现相同的文本高度?

javascript - 如何从 JavaScript 获取 Onclick 图像以落后于所有其他图像

javascript - 在重复表单上使用 jQUERY,随后增加 ID

javascript - 如何找到复选框选中输入的长度?

html - 重叠/覆盖多个内联图像

html - 防止文本换行

css - 在没有 @media 查询或 javascript 的情况下,在较小的屏幕上使用较大的字体?

javascript - 平滑滚动选择更改 jquery

javascript - 在 Ember 中如何使用 View 更改 css 属性然后查看它?

html - Chrome 中的表格样式不同