本篇主要是針對Android系統,所遇到的問題。
- 1. video的全屏處理:
這里說的全屏是指針對瀏覽器的全屏,而不是整個手機的全屏。要想全屏效果只需對video標簽加 webkit-playsinline 。
但是這樣做會有一個問題:針對偏長的手機,視頻會出現居中的效果。針對這種情況,可以對video加屬性 object-fit:fill
<video id="myvideo" src="test.mp4" webkit-playsinline="true" object-fit:fill></video>
- 2. video的自動播放:
自動播放是指頁面加載完畢后,視頻自動開始播放。但是目前而言,Android機是不支持這種自動播放的。
解決辦法:引導用戶觸發滑屏或者touch事件進行觸發 video.play() 進行播放
-
3.移動端設置1px的border:
為解決兼容問題,以下為固定代碼。代碼放置在需要寫border的容器的css樣式里面。
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), color-stop(.5, #ffffff), color-stop(.5, transparent)) top left no-repeat, -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff)) bottom left no-repeat, -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), color-stop(.5, #e8e8e8), color-stop(.5, transparent)) top left no-repeat, -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), to(#e8e8e8)) bottom left no-repeat, #ffffff;
background: -webkit-linear-gradient(90deg, #ffffff, #ffffff) top left no-repeat, -webkit-linear-gradient(270deg, #ffffff, #ffffff) bottom left no-repeat, -webkit-linear-gradient(90deg, #e8e8e8, #e8e8e8, rgba(232, 232, 232, 0)) top left no-repeat, -webkit-linear-gradient(270deg, #e8e8e8, #e8e8e8, rgba(232, 232, 232, 0)) bottom left no-repeat, #ffffff;
background: linear-gradient(0deg, #ffffff, #ffffff) top left no-repeat, linear-gradient(180deg, #ffffff, #ffffff) bottom left no-repeat, linear-gradient(0deg, #e8e8e8, #e8e8e8, rgba(232, 232, 232, 0)) top left no-repeat, linear-gradient(180deg, #e8e8e8, #e8e8e8, rgba(232, 232, 232, 0)) bottom left no-repeat, #ffffff;
-webkit-background-size: 0 0, 0 0, 0 0, 100% 1px;
PS:同時可參考該鏈接:https://zhuanlan.zhihu.com/p/26141351
- 4.移動端頁面左右滑屏問題
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">