HTML5 & custom element & template

template

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

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



<template id="dialog-template">
<script>
document.getElementById('launch-dialog').addEventListener('click', () => {
const wrapper = document.querySelector('.wrapper');
const closeButton = document.querySelector('button.close');
const wasFocused = document.activeElement;
wrapper.classList.add('open');
closeButton.focus();
closeButton.addEventListener('click', () => {
wrapper.classList.remove('open');
wasFocused.focus();
});
});
</script>
<style>
.wrapper {
opacity: 0;
transition: visibility 0s, opacity 0.25s ease-in;
}
.wrapper:not(.open) {
visibility: hidden;
}
.wrapper.open {
align-items: center;
display: flex;
justify-content: center;
height: 100vh;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 1;
visibility: visible;
}
.overlay {
background: rgba(0, 0, 0, 0.8);
height: 100%;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
}
.dialog {
background: #ffffff;
max-width: 600px;
padding: 1rem;
position: fixed;
}
button {
all: unset;
cursor: pointer;
font-size: 1.25rem;
position: absolute;
top: 1rem;
right: 1rem;
}
button:focus {
border: 2px solid blue;
}
</style>
<div class="wrapper">
<div class="overlay"></div>
<div class="dialog" role="dialog" aria-labelledby="title" aria-describedby="content">
<button class="close" aria-label="Close">️</button>
<h1 id="title">Hello world</h1>
<div id="content" class="content">
<p>This is content in the body of our modal</p>
</div>
</div>
</div>
</template> <button id="launch-dialog">Launch dialog</button>
const template = document.getElementById('dialog-template');

document.body.appendChild(
document.importNode(template.content, true)
);

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

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

<command
type="command"
label="Save"
icon="icons/save.png"
onclick="save()"
/>

2018

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

2020

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



最新文章

  1. AndroidStudio Rename Package
  2. Parallel 试验
  3. ASP.NET MVC+EF在服务端分页使用jqGrid以及jquery Datatables的注意事项
  4. Android 6.0权限
  5. MapReduce排序输出
  6. iOS UIBezierPath知识介绍
  7. Eclipse导入工程中文乱码问题
  8. 使用DDMS测试安卓手机APP的性能(android)
  9. php单引号、双引号与数据库
  10. MSSQL BACKUP WEBSHELL
  11. cmd dos 下 无法显示中文
  12. python的正则表达式 re
  13. linux添加swap
  14. js 动态 key value
  15. 02 Java类的加载机制
  16. 【推荐】免费,19 款仿 Bootstrap 后台管理主题下载
  17. 通过分析HSL/HSB获取图片主色调
  18. es6 语法 (symbol)
  19. Javascript重点汇总
  20. c++中的类(class)-----笔记(类简介)

热门文章

  1. Tensorflow-各种优化器总结与比较
  2. 洛谷P2687 &amp; P1108
  3. Python 学习笔记(1)
  4. yuan先生博客地址
  5. java日期
  6. linux 用户、用户组及相关命令(useradd 、passwd、userdel 、groupadd 、groupdel、usermod 、gpasswd 、 id、su)
  7. CCF-交通规划-dijkstra+贪心
  8. Java之jdk环境变量配置
  9. Java反射应用--2
  10. cassandra权威指南读书笔记--cassandra查询语言