[英]Windows Phone 8 Javascript canvas not on whole page
我正在創建Windows Phone8 Javascript應用程序。
但是我有一個我無法解決的問題。
我正在使用畫布,但是畫布處於縱向模式,僅占屏幕的1/4 ...(在諾基亞Lumia 520上開發)
我的畫布的寬度和高度是:
canvas.width = window.innerWidth; //480
canvas.height = window.innerHeight; //800
我的CSS:
* { margin:0; padding:0; } /* to remove the top and left whitespace */
html, body { width:100%; height:100%; } /* just to be sure these are full screen*/
@media screen and (-ms-view-state: fullscreen-landscape) {
}
@media screen and (-ms-view-state: filled) {
}
@media screen and (-ms-view-state: snapped) {
}
@media screen and (-ms-view-state: fullscreen-portrait) {
}
我的XAML:
<Grid x:Name="LayoutRoot" Background="Transparent">
<phone:WebBrowser x:Name="Browser"
Loaded="Browser_Loaded"
NavigationFailed="Browser_NavigationFailed"
IsScriptEnabled="True"
/>
</Grid>
已加載事件:
private void Browser_Loaded(object sender, RoutedEventArgs e)
{
// Add your URL here
Browser.Navigate(new Uri(MainUri, UriKind.Relative));
}
任何人都知道我在整個頁面上使用我的畫布所缺少的嗎?
這似乎可行:
window.devicePixelRatio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth;
W = (window.innerWidth / window.devicePixelRatio); // Window's width
H = (window.innerHeight / window.devicePixelRatio); // Window's height
canvas.width = W;
canvas.height = H;
備注:它可以在人像模式下使用,但不能在風景下...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.