
如圖,考慮到用戶體驗的問題,一般頁面的下方提交按鈕都會隨着固定在頁面上,方便用戶點擊。
有些人肯定就說了,這還不簡單,position:fixed;
但是在ios這個坑貨系統上這個position:fixed這個css屬性就會失效,你懂的,蘋果就是搞特殊,下面我就用css來解決這個問題。
1.這個是要滑動的內容的css:
.page-content {
overflow: auto;
-webkit-overflow-scrolling: touch;
box-sizing: border-box;
height: 100%;
position: relative;
z-index: 1;
}
暫且我就將它的內容區域命名page-content,即html內容為
<div class="page-content">這個是可以滑動的內容區域</div>
2.這個是固定在頁面上的區域:
<div class="scroll-page">這個是按鈕</div>
.scroll-page{
position: fixed;
bottom: 0;
width: 100%;
height: 50px;
background: #f8105c;
color: white;
text-align: center;
line-height: 50px;
font-size: 18px;
z-index: 99;
}
這樣的話可以完美解決這個fixed在ios上失效的問題。親測有效!!!!!!網上搜的其它方法,大都有這樣那樣的問題
