--window-top和--window-bottom

APP 和微信的原生导航栏和tabbar下,元素区域坐标是不包含原生导航栏和tabbar的。而 H5 里原生导航栏和tabbar是 div 模拟实现的,所以元素坐标会包含导航栏和tabbar的高度。为了优雅的解决多端高度定位问题,uni-app新增了2个css变量:–window-top和–window-bottom,这代表了页面的内容区域距离顶部和底部的距离。举个实例,如果你想在原生tabbar上方悬浮一个菜单,之前写bottom:0。这样的写法编译到h5后,这个菜单会和tabbar重叠,位于屏幕底部。而改为使用bottom:var(–window-bottom),则不管在app下还是在h5下,这个菜单都是悬浮在tabbar上浮的。这就避免了写条件编译代码。当然你也仍然可以使用 H5 的条件编译处理界面的不同。

CSS內使用vh单位的时候注意100vh包含导航栏,使用时需要减去导航栏和tabBar高度,部分浏览器还包含浏览器操作栏高度,使用时请注意。’

https://ask.dcloud.net.cn/article/35232

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是C语言实现的Cohen-Sutherland算法代码: #include <stdio.h> #include <graphics.h> #define INSIDE 0 #define LEFT 1 #define RIGHT 2 #define BOTTOM 4 #define TOP 8 int xmin, ymin, xmax, ymax; int ComputeOutCode(int x, int y) { int code = INSIDE; if (x < xmin) { code |= LEFT; } else if (x > xmax) { code |= RIGHT; } if (y < ymin) { code |= BOTTOM; } else if (y > ymax) { code |= TOP; } return code; } void CohenSutherland(int x1, int y1, int x2, int y2) { int outcode1 = ComputeOutCode(x1, y1); int outcode2 = ComputeOutCode(x2, y2); while (1) { if (!(outcode1 | outcode2)) { // Both points inside window line(x1, y1, x2, y2); break; } else if (outcode1 & outcode2) { // Both points outside window and same region break; } else { int x, y, outcode; // At least one endpoint is outside the window if (outcode1) { outcode = outcode1; } else { outcode = outcode2; } // Find intersection point if (outcode & TOP) { x = x1 + (x2 - x1) * (ymax - y1) / (y2 - y1); y = ymax; } else if (outcode & BOTTOM) { x = x1 + (x2 - x1) * (ymin - y1) / (y2 - y1); y = ymin; } else if (outcode & RIGHT) { y = y1 + (y2 - y1) * (xmax - x1) / (x2 - x1); x = xmax; } else if (outcode & LEFT) { y = y1 + (y2 - y1) * (xmin - x1) / (x2 - x1); x = xmin; } // Update the point and outcode if (outcode == outcode1) { x1 = x; y1 = y; outcode1 = ComputeOutCode(x1, y1); } else { x2 = x; y2 = y; outcode2 = ComputeOutCode(x2, y2); } } } } int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); xmin = 50; ymin = 50; xmax = 200; ymax = 200; rectangle(xmin, ymin, xmax, ymax); // Test cases CohenSutherland(10, 10, 300, 300); CohenSutherland(0, 150, 250, 150); CohenSutherland(150, 0, 150, 250); CohenSutherland(250, 250, 350, 350); getch(); closegraph(); return 0; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值