HTML5 & custom element & template

template

https://codepen.io/xgqfrms/pen/eYYExvp

https://css-tricks.com/creating-a-custom-element-from-scratch/

  1. <template id="dialog-template">
  2. <script>
  3. document.getElementById('launch-dialog').addEventListener('click', () => {
  4. const wrapper = document.querySelector('.wrapper');
  5. const closeButton = document.querySelector('button.close');
  6. const wasFocused = document.activeElement;
  7. wrapper.classList.add('open');
  8. closeButton.focus();
  9. closeButton.addEventListener('click', () => {
  10. wrapper.classList.remove('open');
  11. wasFocused.focus();
  12. });
  13. });
  14. </script>
  15. <style>
  16. .wrapper {
  17. opacity: 0;
  18. transition: visibility 0s, opacity 0.25s ease-in;
  19. }
  20. .wrapper:not(.open) {
  21. visibility: hidden;
  22. }
  23. .wrapper.open {
  24. align-items: center;
  25. display: flex;
  26. justify-content: center;
  27. height: 100vh;
  28. position: fixed;
  29. top: 0;
  30. left: 0;
  31. right: 0;
  32. bottom: 0;
  33. opacity: 1;
  34. visibility: visible;
  35. }
  36. .overlay {
  37. background: rgba(0, 0, 0, 0.8);
  38. height: 100%;
  39. position: fixed;
  40. top: 0;
  41. right: 0;
  42. bottom: 0;
  43. left: 0;
  44. width: 100%;
  45. }
  46. .dialog {
  47. background: #ffffff;
  48. max-width: 600px;
  49. padding: 1rem;
  50. position: fixed;
  51. }
  52. button {
  53. all: unset;
  54. cursor: pointer;
  55. font-size: 1.25rem;
  56. position: absolute;
  57. top: 1rem;
  58. right: 1rem;
  59. }
  60. button:focus {
  61. border: 2px solid blue;
  62. }
  63. </style>
  64. <div class="wrapper">
  65. <div class="overlay"></div>
  66. <div class="dialog" role="dialog" aria-labelledby="title" aria-describedby="content">
  67. <button class="close" aria-label="Close"></button>
  68. <h1 id="title">Hello world</h1>
  69. <div id="content" class="content">
  70. <p>This is content in the body of our modal</p>
  71. </div>
  72. </div>
  73. </div>
  74. </template>
  75. <button id="launch-dialog">Launch dialog</button>
  1. const template = document.getElementById('dialog-template');
  2. document.body.appendChild(
  3. document.importNode(template.content, true)
  4. );

  1. #launch-dialog {
  2. background: tomato;
  3. border-radius: 4px;
  4. color: #fff;
  5. font-family: Helvetica, Arial, sans-serif;
  6. padding: 0.5rem 1rem;
  7. position: static;
  8. }

web components & custom elements

https://www.html5rocks.com/en/tutorials/webcomponents/customelements/

https://developers.google.com/web/fundamentals/web-components/customelements



HTML5 & command element

https://www.quackit.com/html_5/tags/html_command_tag.cfm

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/command

  1. <command
  2. type="command"
  3. label="Save"
  4. icon="icons/save.png"
  5. onclick="save()"
  6. />

2018

https://caniuse.com/#search=command

2020

https://caniuse.com/#search=command



HTML5 & custom element & template的更多相关文章

  1. WebComponent魔法堂:深究Custom Element 之 从过去看现在

    前言  说起Custom Element那必然会想起那个相似而又以失败告终的HTML Component.HTML Component是在IE5开始引入的新技术,用于对原生元素作功能"增强& ...

  2. HTML语义化:HTML5新标签——template

    一.前言 当我们使用String-base的模板引擎(如Handlebars.js等)时,要么就通过外部文件存放模板文本,需要时再通过XHR或script标签加载进来:要么通过<script t ...

  3. 使用vue.js路由踩到的一个坑Unknown custom element

    在配合require.js使用vue路由的时候,遇到了路由组件报错: “vue.js:597 [Vue warn]: Unknown custom element: <router-link&g ...

  4. Vue报错之" [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component correctly? For recursive components, make sure to provide the "name" option."

    一.报错截图 [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component corre ...

  5. WebComponent魔法堂:深究Custom Element 之 标准构建

    前言  通过<WebComponent魔法堂:深究Custom Element 之 面向痛点编程>,我们明白到其实Custom Element并不是什么新东西,我们甚至可以在IE5.5上定 ...

  6. WebComponent魔法堂:深究Custom Element 之 面向痛点编程

    前言  最近加入到新项目组负责前端技术预研和选型,一直偏向于以Polymer为代表的WebComponent技术线,于是查阅各类资料想说服老大向这方面靠,最后得到的结果是:"资料99%是英语 ...

  7. angular custom Element 自定义web component

    angular 自定义web组件: 首先创建一个名为myCustom的组件. 引入app.module: ... import {customComponent} from ' ./myCustom. ...

  8. (错误记录)Vue: Unknown custom element

    错误: vue.js:634 [Vue warn]: Unknown custom element: <ve-pie> - did you register the component c ...

  9. vue报错[Vue warn]: Unknown custom element: <router-Link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

    vue浏览器报错,如下 vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <router-Link> - di ...

随机推荐

  1. 我的刷题单(8/37)(dalao珂来享受切题的快感

    P2324 [SCOI2005]骑士精神 CF724B Batch Sort CF460C Present CF482A Diverse Permutation CF425A Sereja and S ...

  2. docker通过dockerfile构建JDK最小镜像,Docker导出导入镜像

    docker通过dockerfile构建JDK最小镜像,Docker导出导入镜像 一.docker通过dockerfile构建JDK最小镜像 1.1 下载JRE 1.2 解压JRE,删除相关不需要文件 ...

  3. hibernate+spring+tomcat启动报错Not supported by BasicDataSource

    最近使用hibernate+spring+jsp的小项目制作过程中出现一些错误,例如: java.lang.UnsupportedOperationException: Not supported b ...

  4. $().arr使用

    $("#handmoney").attr("readonly","readonly"); 只读 $("img").att ...

  5. 【数组】leetcode——移除元素

    编号:27. 移除元素 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度. 不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 ...

  6. 2019牛客暑期多校训练营(第八场)A-All-one Matrices(单调栈+思维)

    >传送门< 题意:给你一个01矩阵,求出所有不可扩大的全为1的矩阵的个数 思路:比赛的时候想到了用单调栈,但是也只是想到了,并不知道怎么用,其实和之前求二维01矩阵中全为1的矩阵最大面积非 ...

  7. 洛谷P3796

    题目链接  题意:有n个由小写字母组成的模式串以及一个文本串T.每个模式串可能会在文本串中出现多次.哪些模式串在文本串T中出现的次数最多. 题解:ac自动机模板加强版,开一个数组单独记录各个字符串出现 ...

  8. Codeforces Round #646 (Div. 2) E. Tree Shuffling dfs

    题意: 给你n个节点,这n个节点构成了一颗以1为树根的树.每一个节点有一个初始值bi,从任意节点 i 的子树中选择任意k个节点,并按他的意愿随机排列这些节点中的数字,从而产生k⋅ai 的成本.对于一个 ...

  9. POJ_2112 二分图多重匹配

    题意: //题意就是给你k个挤奶池和c头牛,每个挤奶池最多可以来m头牛,而且每头牛距离这k这挤奶池//有一定的距离,题目上给出k+c的矩阵,每一行代表某一个物品距离其他物品的位置//这里要注意给出的某 ...

  10. POJ2785 4 Values whose Sum is 0 (二分)

    题意:给你四组长度为\(n\)序列,从每个序列中选一个数出来,使得四个数字之和等于\(0\),问由多少种组成情况(仅于元素的所在位置有关). 题解:\(n\)最大可以取4000,直接暴力肯定是不行的, ...