unity3d画布切换

Large sites shown in small viewports increasingly use an “off-canvas” UI model, which site navigation is hidden, and only revealed when the user calls for it.

在小视口中显示的大型站点越来越多地使用“非画布” UI模型,该模型隐藏了站点导航 ,并且仅在用户要求时才显示。

The site that you’re reading now uses a variation of the technique that might be called “under-canvas”: if the browser window is narrow enough, the site navigation is hidden beneath the site content, and revealed by sliding the content to one side.

您正在阅读的网站现在使用一种可能称为“画布底”的技术变体:如果浏览器窗口足够狭窄,则网站导航将隐藏网站内容下方 ,并通过将内容滑动到一个位置来显示侧。

Either model works well in responsive design, but it’s also possible to have site navigation folded within the page, rather than above or below the main canvas area.

两种模型都可以在响应式设计中很好地工作,但是也可以页面而不是在主画布区域上方或下方折叠站点导航。

Conventional “off-canvas” navigation, showing options for bringing in UI controls from the left.
常规的“画布外”导航,显示用于从左侧引入UI控件的选项。

To make this happen, I have used three separate markup sections: one containing the top-level navigation, a hidden section containing expanded site navigation, and the main content, all wrapped inside a container element. In markup, it would look like this:

为了实现这一点,我使用了三个单独的标记部分:一个包含顶层导航,一个隐藏部分包含扩展的站点导航,以及主要内容,所有内容都包装在一个容器元素中。 在标记中,它看起来像这样:

<div id="foldout"><div id="base-navigation" class="ss-icon"><a href="#">rows</a><a href="#">heart</a><a href="#">star</a><a href="#">grid</a><a href="#">help</a></div><div id="hidden-navigation"><a href="#">HTML</a><a href="#">CSS</a><a href="#">PHP</a><a href="#">MySQL</a></div><div id="foldout-text-content"><img src="himalayas.jpg" alt><h1>Hwæt!</h1><p>We gardena - in geardagum, þeodcyninga…</div>
</div>

I’m using the semantic ligature font SS Standard to create the navigation icons.

我正在使用语义连字字体 SS标准来创建导航图标。

We’ll use CSS to give each section the appearance of a fold. Seen in perspective, the “closed” state of the sections would look like this:

我们将使用CSS为每个部分赋予折叠外观。 从透视图看,各节的“关闭”状态如下所示:

Navigation shown in folded state
导航以折叠状态显示

When open, it looks like this:

打开后,它看起来像这样:

Navigation shown in unfolded state
导航以展开状态显示

Perhaps a little oddly, I’ll use display: table-cell to place the sections side-by-side. It turns out that you can use CSS 3D on HTML tables, which gives rise to many possibilities for roll-out or roll-up table data. Using traditional floats, positioning or flexbox are also possibilities.

也许有些奇怪,我将使用display: table-cell来将各节并排放置。 事实证明,可以在HTML表格上使用CSS 3D ,这为展开或汇总表格数据提供了许多可能性。 也可以使用传统的浮子, 定位或柔箱 。

#foldout {perspective: 1200px;
}
#base-navigation,#hidden-navigation,#foldout-text-content {display: table-cell;vertical-align: top;transition: 1s transform, box-shadow ease; }
#base-navigation,#foldout-text-content {background: hsla(43, 100%, 95%, 1);}

The containing element has perspective applied. Each section has the same properties and values applied (sans vendor prefixes to save space).

包含元素已应用透视图 。 每个部分均具有相同的属性和值(不使用供应商前缀以节省空间)。

I won’t focus on the CSS for the site navigation on the left side, since that is not the focus of this article; instead, I’ll proceed to the styles for the section that is folded back:

我不会在左侧进行站点导航CSS,因为这不是本文的重点。 相反,我将继续进行折回部分的样式:

#hidden-navigation {width: 180px;transform-origin: 0 0 0;transform: rotateY(-75deg);
}
#hidden-navigation a {line-height: 2;color: #222;border-bottom: 1px solid #000;padding-left: .5rem;
}
#hidden-navigation a:hover {background: #222;color: hsla(43, 100%, 98%, 1);
}
#hidden-navigation a:last-child {border-bottom: none;
}

The hidden section is “hinged” from its left-hand side by changing the transform-origin of the element.

通过更改元素的transform-origin ,隐藏部分从左侧“铰接”。

#foldout-text-content {width: 80%;transform: translateX(-85px) translateZ(125px); box-shadow: -8px 0 12px rgba(0,0,0,0.1);
}

The main content area is moved closer to the screen and to the left to meet the edge of the folded navigation. I used translate rather than rotate as the latter will rotate the entire section of content, distorting it.

主要内容区域移至靠近屏幕的位置,并向左移,以适应折叠式导航的边缘。 我使用translate而不是rotate因为后者将旋转内容的整个部分,从而扭曲它。

Before wiring in the JavaScript to engage the motion, I thought it would be easier to create it using hover states first. Both the fold and the main content area will move: the former rotating and changing color very slightly to give the impression that it catches more light, while the former translates across, its shadow disappearing for the same reason.

在连接JavaScript进行动作之前,我认为先使用悬停状态创建动作会更容易。 折叠区域和主要内容区域都将移动:前者会非常轻微地旋转和改变颜色,从而给人留下更多的光线,而前者平移时,其阴影消失的原因相同。

#foldout:hover #foldout-text-content {transform: translateX(-3px) translateZ(15px);box-shadow: 0 0 0 rgba(0,0,0,0.1);
}
#foldout:hover #hidden-navigation {transform: rotateY(-10deg);background: hsla(43, 100%, 98%, 1);
}

The solution also nicely responsive, as you’ll see by resizing the browser when the menu is in its open state: I’ve also added some CSS to devolve the UI as the viewport narrows further.

该解决方案的响应也很好,正如您将在菜单处于打开状态时调整浏览器大小所看到的那样:随着视口范围进一步缩小,我还添加了一些CSS来使UI旋转。

JavaScript连线 (Wiring In The JavaScript)

Making actions happen “on click” is notoriously difficult in CSS. While pure CSS techniques utilizing :target, :focus and :checked states exist, it’s usually easier to turn to JavaScript.

在CSS中,使操作“单击”发生非常困难。 虽然存在利用:target:focus:checked状态的纯CSS技术,但通常更容易转向JavaScript 。

The solution is surprisingly easy: rather than  activating the transition on hover, we’ll do so by changing the class on the container element:

该解决方案非常简单:与通过悬停激活过渡相比,我们将通过更改容器元素上的类来实现:

#foldout.open-sesame #foldout-text-content {transform: translateX(-3px) translateZ(15px);box-shadow: 0 0 0 rgba(0,0,0,0.1);
}
#foldout.open-sesame #hidden-navigation {transform: rotateY(-10deg);background: hsla(43, 100%, 98%, 1);
}

Then add and remove this class with a little JavaScript:

然后使用一些JavaScript添加和删除此类:

var foldouttrigger = document.querySelector("#base-navigation a:first-child");
var foldout = document.getElementById("foldout");
foldouttrigger.addEventListener("click", function() {foldout.classList.toggle("open-sesame");
})

That’s it: the in-fold navigation is complete.

就是这样:内置导航已完成。

缺点 (Downsides)

Hardware and software are the two significant limiting factors of this approach. While well-supported in all other browsers, Microsoft only began to support 3D transform standards in IE 10; the fact that the entire main content area is held and transformed in 3D could prove taxing for lower-end devices, especially if there was a great deal of content.

硬件和软件是此方法的两个重要限制因素。 尽管在所有其他浏览器中都得到了很好的支持,但是Microsoft才开始在IE 10中支持3D转换标准。 整个主要内容区域都以3D形式保存和转换的事实可能会证明对低端设备造成了负担,尤其是在存在大量内容的情况下。

翻译自: https://thenewcode.com/704/In-Canvas-3D-Fold-Navigation

unity3d画布切换

unity3d画布切换_画布内3D折叠导航相关推荐

  1. 笔记本电脑键盘切换_全球首款折叠屏笔记本电脑ThinkPad X1 Fold:5G高速互联拥抱PC场景融合时代...

    10月22日,联想在ThinkPad X1 Fold思想发布会上正式发布了全球首款折叠屏笔记本电脑ThinkPad X1 Fold,并宣布了5G版在全球首销. 这款划时代的笔记本电脑集合了众多前沿技术 ...

  2. 全球与中国3D透视导航技术市场现状及未来发展趋势(2022)

    本文研究全球及中国市场3D透视导航技术现状及未来发展趋势,侧重分析全球及中国市场的主要企业,同时对比北美.欧洲.中国.日本.东南亚和印度等地区的现状及未来发展趋势. 根据QYR(恒州博智)的统计及预测 ...

  3. 2022-2028全球3D透视导航技术行业调研及趋势分析报告

    据恒州诚思调研统计,2021年全球3D透视导航技术市场规模约 亿元,2017-2021年年复合增长率CAGR约为 %,预计未来将持续保持平稳增长的态势,到2028年市场规模将接近 亿元,未来六年CAG ...

  4. python创建画布大小_要绘制图形,首先需要显示画布,并设置画布的大小。其中turtle.setup()函数可以显示画布,并设置画布的大小,及画布在屏幕上的相对位置。_学小易找答案...

    [简答题]大脑左半球: [其它]11- 15 [简答题]音乐教育能 [单选题]177. 下列哪种方法不属于机械清蜡方法?( ) [判断题]审美价值的特性--精神性. [单选题]168. 储层改造技术也 ...

  5. Python设置画布大小_我用Python的Seaborn库绘制17个超好看图表

    点击上方" Python爬虫与数据挖掘 ",进行关注 回复"书籍"即可获赠Python从入门到进阶共10本电子书 今 日 鸡 汤 风朝露夜阴晴里,万户千门开闭时 ...

  6. canvas在画布上创建向上下左右3D影子文字

    canvas在画布上创建向上下左右3D影子文字 简单实现canvas中的文字3D影子;如有代码问题请留言,谢谢; <!DOCTYPE html> <html><head& ...

  7. python画布位置_如何调整tkinter画布的位置

    在我的程序中,我想创建一个锚定在屏幕左上角的tkinter画布,但画布默认位于屏幕上的另一个位置.以下是这一情况的图像: 以下是我当前的代码:#!/usr/bin/python import tkin ...

  8. 摘自人民网体育频道的JS卷角翻转方块图片切换_网页代码站(www.webdm.cn)

    1 <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o ...

  9. 【初阶】unity3d官方案例_太空射击SpacingShooter 学习笔记 显示分数时,如何让函数之间相互交流...

    [初阶]unity3d官方案例_太空射击SpacingShooter 学习笔记 显示分数时,如何让函数之间相互交流 一.关于 显示分数时,如何让函数之间相互交流 这是一个非常好的逻辑问题 1 思路:主 ...

最新文章

  1. wps 模拟分析 规划求解_入行十年,我是如何解决模流分析准确性问题的
  2. [原创]浅谈对华为34岁以上员工“退休”
  3. 历届试题 密码发生器
  4. id3与软件测试,ID3算法的实现
  5. 高通要大干无人机芯片 耗时一年获总部飞行许可
  6. python编写接口初识一
  7. 安卓自定义时间选择器_微信小程序拾色器(颜色选择器)组件
  8. 搞笑创意海报灵感|终于知道设计该怎么做了!
  9. 《编写可维护的JavaScript》——2.2 多行注释
  10. LNMP(Nginx服务,MySQL 服务,安装PHP服务 手动安装技术文档)
  11. Linux安装网易云音乐
  12. java开发英语词典app_英语词典app哪个好 5款好用的英语词典app推荐
  13. 微信查询对账单对账+数据读取解析入库
  14. 政府行业数据保护方案
  15. wps教鞭功能_你未必知道的WPS神奇功能
  16. 《数字图像处理》冈萨雷斯,Matlab函数汇总 .
  17. 《Braid》碎片式台词
  18. 晴园直播(全球直播)订阅源+轻站+海阔小程序
  19. 7种垃圾收集器与内存分配策略,看这一篇就够了
  20. 音乐欣赏课程笔记(一)

热门文章

  1. 第一章踏上python之旅_神界之唯我逍遥
  2. 元宇宙的东风吹向何处?企业如何乘势布局?
  3. ant Design 中使用 :globa
  4. 拯救007(升级版) 解题报告
  5. 微信小程序【网易云音乐实战】(第六篇 歌曲搜索、自定义模板、分包)
  6. 使用Python爬出王者荣耀高清皮肤图片
  7. jmpi 与ljmp指令分析
  8. 优思学院|六西格玛设计方法IDDOV是什么?
  9. Linux修复文件系统
  10. 我的mybatis plus——全公司同事开始模仿了!