理想的には、div要素は一切幅と高さが宣言を持っていないはずです(意味:コンテンツは、それは寸法だ決定させる)
$('div_selector_here').on('click',function(){
//try one of the following:
//they both stretch the div to the image IF it has no width and height declared:
// if width and height are declared for the div, this will leak the image out of the container
$(this).css('overflow','visible');
//if width and height are declared for the div, this will add scrollbars
$(this).css('overflow','auto');
});
加えて、あなたは画像をdiv要素にぴったりされていることを確認し、これを追加することができます(そして再び、それはあなたがdiv要素に幅と高さを設定しない考えです):
img{
display:block;
width:100%;
}
'$(this).css( 'overflow'、 'visible');'は親に対してこれをやろうとしているので動かないでしょう。私はあなたが後で言ったことを考えていましたが、これが可能かどうかを調べるつもりです。 – Starx
あなたは試しましたか? '$(this).parent().css( 'overflow'、 'visible');' –