私は検索と即興を行ってきましたが、これを思いつきました:
$(window).resize(function() {
function imgResize()
{
if ($("#post_container img").width() > $("#post_container img").height()){
$('#post_container img').css({ 'width': '80%', 'height': 'auto' });
}
else if ($("#post_container img").width() < $("#post_container img").height()){
$('#post_container img').css({ 'width': 'auto', 'height': '80%' });
}
else {
$('#post_container img').css({ 'width': '80%', 'height': 'auto' });
}
}
})
ウィンドウのサイズを変更するときに、画像が縦向きか横向きかを検出し、画面全体に収まるようにサイズを変更する必要があるため、そのコードは正しいですか。