这似乎适用于 iOS 12.4.2 上的 iphone 6 Plus 上的 Ionic5
.large_player {
float: left;
bottom: 0;
width: 100%;
position: fixed;
background-color: white;
border-top: black 1px solid;
height: 14rem;
z-index: 100;
transform: translate3d(0,0,0);
}
transform 标签使它工作,但它在滚动的工作方式上似乎有点笨拙,它似乎在它全部移动后重新绘制“顶部”元素并进行某种重置并使其跳跃一点.
或者,您也可以使用此标记选项,position: -webkit-sticky;,但是您不会得到,或者可能会遇到 WPA/浏览器或 Android 构建的问题,同时必须进行版本检查并拥有多个 CSS标签。
.large_player {
float: left;
bottom: 0;
width: 100%;
position: -webkit-sticky;
background-color: white;
border-top: black 1px solid;
height: 14rem;
z-index: 100;
}
我不知道它是在什么时候修复的,但后来的 iOS 手机可以在没有转换标签的情况下工作。不知道是iOS版还是手机版。
由于大多数 iOS 设备通常都使用最新的 iOS 版本,因此使用一些奇怪的解决方法是相当安全的 - 例如使用transform 标签,而不是为了少于1% 的用户。
更新:
在进一步考虑这个答案后,这只是 ionic5+ 平台的另一种方式:
.TS
import {Platform } from '@ionic/angular';
constructor(
public platform: Platform
)
{
// This next bit is so that the CSS is shown correctly for each platform
platform.ready().then(() => {
if (this.platform.is('android')) {
console.log("running on Android device!");
this.css_iOS = false;
}
if (this.platform.is('ios')) {
console.log("running on iOS device!");
this.css_iOS = true;
}
if (this.platform.is('ipad')) {
console.log("running on iOS device!");
this.css_iOS = true;
}
});
}
css_iOS: boolean = false;
.HTML
<style *ngIf="css_iOS">
.small_player {
position: -webkit-sticky !important;
}
.large_player {
position: -webkit-sticky !important;
}
</style>
<style>
.small_player {
float: left;
bottom: 0;
width: 100%;
position: fixed;
background-color: white;
border-top: black 1px solid;
height: 4rem;
z-index: 100;
/*transform: translate3d(0,0,0);*/
}
.large_player {
float: left;
bottom: 0;
width: 100%;
position: fixed;
background-color: white;
border-top: black 1px solid;
height: 14rem;
z-index: 100;
/*transform: translate3d(0,0,0);*/
}
</style>