<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Jquery] height in proporzione alla larghezza della della finestra]]></title><description><![CDATA[<p dir="auto">In un template responsive non potendo impostare una altezza fissa di una immagine nè potendo utilizzare height:auto calcolo l'altezza dell'immagine in base alla larghezza della finestra del browser con il seguente codice:</p>
<p dir="auto">$(document).ready(function() {<br />
var bodywidth = $(document).width();<br />
var ratioheight = (bodywidth/3.582);<br />
$("<a href="/hashtags/gallery">#gallery</a>").height(ratioheight);<br />
});</p>
<p dir="auto">// for the body resize active<br />
$(window).resize(function() {<br />
var bodywidth = $(document).width();<br />
var ratioheight = (bodywidth/3.582);<br />
$("<a href="/hashtags/gallery">#gallery</a>").height(ratioheight);<br />
});</p>
<p dir="auto">Funziona bene ma sul mobile (iphone/ipad) succede che passando da portrait a landscape l'altezza dell'immagine non venga ricalcolata e quindi in modalità landscape l'immagine ha dimensioni più piccole.</p>
<p dir="auto">Qualcuno può darmi una mano per capire come implementare una funzione del genere?:</p>
<p dir="auto">$(window).bind('orientationchange resize', function(event){<br />
if(event.orientation) {<br />
if(event.orientation == 'portrait') {<br />
// do something<br />
} else if (event.orientation == 'landscape') {<br />
// do something else<br />
}<br />
} else {<br />
// optional... PC-version javascript for example<br />
}</p>
<pre><code>  });
</code></pre>
<p dir="auto">Grazie in anticipo.</p>
]]></description><link>https://dev.connect.gt/topic/180249/jquery-height-in-proporzione-alla-larghezza-della-della-finestra</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 07:24:40 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/180249.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Nov 2012 13:54:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Jquery] height in proporzione alla larghezza della della finestra on Tue, 27 Nov 2012 22:11:40 GMT]]></title><description><![CDATA[<p dir="auto">&lt;body onresize="Quellochevuoi();"&gt;</p>
]]></description><link>https://dev.connect.gt/post/1096189</link><guid isPermaLink="true">https://dev.connect.gt/post/1096189</guid><dc:creator><![CDATA[yudoit]]></dc:creator><pubDate>Tue, 27 Nov 2012 22:11:40 GMT</pubDate></item></channel></rss>