phonegap(cordova)フレームワークを使用してios/androidアプリを作成しています。私のUIコードは、水平方向に少し欠けています。ですから、縦向きではなく横向きだけにルックアンドフィールを変えたいと思います。これを達成するためにindex.htmlで、できれば。で適用できる条件はありますかjavascript/jquery
。前もって感謝します。
1 に答える
0
イベント onOrientationChange() のイベント リスナーを作成すると、特定の方向に適用される css ファイルをおそらく変更できます。
// create the link tag for the css file in your head section
<HEAD>
<LINK ID="OrientationSpecificCSSTag" REL="stylesheet" TYPE="text/css" HREF=""> // keep the href empty, will set later
.....
</HEAD>
ここで、JavaScript ファイルまたはスクリプト タグにイベント リスナーをアタッチします。
// attach the onOrientationChange event listener in your script tag
window.addEventListener( 'onorientationchange', OnOrientationChange, false );
向きに応じて css ファイルを実際に変更する OnOrientationChange 関数を実装します。
function OnOrientationChange()
{
// case: if portrait
if( window.orientation == 0 || window.orientation == 270 )
{
document.getElementById('OrientationSpecificCSSTag').HREF = 'landscape.css';
}
else
{
document.getElementById('OrientationSpecificCSSTag').HREF = 'portrait.css';
}
}
于 2012-12-26T05:47:56.403 に答える