From d27c6e48aa3cecd618e4a5756826984918b5b261 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Thu, 25 Jan 2024 12:02:18 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0uni-app-x=20position?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/css/position.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/css/position.md b/docs/css/position.md index 8b6ad1fc..c132cbe5 100644 --- a/docs/css/position.md +++ b/docs/css/position.md @@ -15,6 +15,27 @@ #### App平台差异 + absolute元素相对父组件确定位置,fixed元素位于页面顶层。 +#### fixed定位@fixed + +position: fixed定位时,web端为相对于整个浏览器页面进行定位,app端为相对于页面(除导航栏、tabbar)定位。可以使用css变量使两端表现一致 + +```css +.fixed { + position: fixed; + width: 100px; + height: 100px; + background-color: #FF0000; + left: 10px; + /* #ifdef WEB */ + top: calc(--window-top + 10px); + /* #endif */ + /* #ifdef APP */ + top: 10px; /* App端暂不支持calc */ + /* #endif */ +} +``` + \ No newline at end of file -- GitLab