我有一個非常不尋常的錯誤出現在我的Android 4.0 Galaxy Note上。一些朋友在他們的Galaxy S3上看到了相同的效果。我簡化了我的代碼如下:Android CSS位置:設備旋轉後固定
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0,initial-scale=1.0, user-scalable=no" />
<style type="text/css">
#movieplayer {width:100%; position:fixed; top:0px; left:0px; right:0px; bottom:0; background:yellow; z-index: 90;}
.player, .project-info {width:100%}
#movieplayer .short-info {width:100%;background:green;display:block;position:relative;}
</style>
</head>
<body class="works">
<div id="global-container">
<div id="movieplayer">
<div class="player">
<div class="project-info movie">
<div class="short-info jspScrollable">
<div class="container">
hello
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
當你第一次加載在肖像這個頁面,你會看到在黃色背景上一個綠色條。它們都填滿了屏幕寬度的100%。將手機旋轉到橫向時,黃色會繼續填充屏幕的其餘部分,但綠色條不能填充剩餘寬度。爲什麼是這樣?
我在這裏使用#movieplayer {position:fixed;},因爲在我的真實代碼中,我依靠它來做一些其他的事情。所以我不能使用position:absolute。
對方回答是更好的方式,它只是工作! – Adaptabi 2013-09-19 21:33:26
爲我修復了它。 – 2015-11-11 11:08:42