flex 實現移動端上下固定,中間滑動

2021-10-08 18:22:12 字數 1362 閱讀 1470

如果你還在用position:fixed來保持移動端頂部、下部的導航欄在全域性固定位置不動。

那你可以換種方法。更簡單,方便,快捷;還不會受定位的影響。

不過注意,使用flex彈性布局的話,需要將設定flex的這個盒子所依賴的父標籤的height有個固定的值,一般就是佔滿全域性height:100%;

大師兄飛速寫完的flex移動端布局小栗子:

lang

="en"

>

>

charset

="utf-8"

>

name

="viewport"

content

="width=device-width, initial-scale=1.0"

>

>

documenttitle

>

head

>

>

body,html

.header

.con

.temp

.footer

style

>

>

class

=>

class

="header"

>

div>

class

="con"

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

class

="temp"

>

111div

>

div>

class

="footer"

>

div>

div>

body

>

html

>

別說,還挺好看。

flex布局實現上下固定高度,中間自適應布局

flex布局在實際開發中越來越常用,實現左右寬度或者上下高度固定,中間自適應的布局的實際需求也很常見。實現起來也很簡單 header main footer 注意點 1 container父容器的高度必須是乙個可以計算出來的固定高度。2 實際開發中因為中間部分內容層級太多,甚至巢狀 等,使得自適應無...

移動端上 下 左 右滑動

在移動端的上 下的移動與現實有很大的差距,分別分兩種情況,如下圖 有三個事件 上滑與下滑相似 1 判斷手指按下時的位置 touchstart startx event.touches 0 pagex starty event.touches 0 pagey 2 判斷手指抬起時的位置 touchend...

實現移動端上拉載入效果

上拉載入的實現思路其實很簡單 1.移動端觸發touchmove事件 上拉 2.判斷最後乙個元素是否已出現在底部 3.若出現,則js新增元素到頁面末尾 思路圖 接下來開始編寫style樣式 html,body li personkit article ul pin personkit article ...