有没有 HTML5 替代 JS 的 Alert Box?

2023-12-09

有没有纯HTML5的选择到 JS 的警报框? 我从未涉足过 JS 或其他脚本/代码,我只对 HTML5 和 CSS3 感到满意,(我真的很喜欢语义:))

如果没有也没关系,好​​奇多于需要。

谢谢! 杰西


HTML5是一个平台和品牌。它包括许多javascript API、CSS3模块等。 尝试使用:target CSS3 example例如,警报。它使用CSS3的顶级功能。

来自笔的代码:

HTML

<div class="wrap">
  <h1>Modal - Pure CSS (no Javascript)</h1>
  <p>Example of modal in CSS only, here I use the pseudo selector ":target" and no javascript for modal action.</p>
  <p>This works in IE9+ and all modern browsers.</p>
  <p>View <a href="http://www.felipefialho.com/css-components/">Pure CSS Components</a> project.</p>
  <hr />
  <a href="#modal-one" class="btn btn-big">Modal!</a>
</div>

<!-- Modal -->
<div class="modal" id="modal-one" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-header">
      <h2>Modal in CSS?</h2>
      <a href="#" class="btn-close" aria-hidden="true">×</a>
    </div>
    <div class="modal-body">
      <p>One modal example here! :D</p>
    </div>
    <div class="modal-footer">
      <a href="#" class="btn">Nice!</a>
    </div>
  </div>
</div>
<!-- /Modal -->

CSS

body {
  color: #333333;
  font-family: 'Helvetica', arial;
}
.wrap {
  padding: 40px;
  text-align: center;
}
hr {
  clear: both;
  margin-top: 40px;
  margin-bottom: 40px;
  border: 0;
  border-top: 1px solid #aaaaaa;
}
h1 {
  font-size: 30px;
  margin-bottom: 40px;
}
p {
  margin-bottom: 20px;
}
.btn {
  background: #428bca;
  border: #357ebd solid 1px;
  border-radius: 3px;
  color: #fff;
  display: inline-block;
  font-size: 14px;
  padding: 8px 15px;
  text-decoration: none;
  text-align: center;
  min-width: 60px;
  position: relative;
  transition: color .1s ease;
}
.btn:hover {
  background: #357ebd;
}
.btn.btn-big {
  font-size: 18px;
  padding: 15px 20px;
  min-width: 100px;
}
.btn-close {
  color: #aaaaaa;
  font-size: 30px;
  text-decoration: none;
  position: absolute;
  right: 5px;
  top: 0;
}
.btn-close:hover {
  color: #919191;
}
.modal:before {
  content: "";
  display: none;
  background: rgba(0, 0, 0, 0.6);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
}
.modal:target:before {
  display: block;
}
.modal:target .modal-dialog {
  -webkit-transform: translate(0, 0);
  -ms-transform: translate(0, 0);
  transform: translate(0, 0);
  top: 20%;
}
.modal-dialog {
  background: #fefefe;
  border: #333333 solid 1px;
  border-radius: 5px;
  margin-left: -200px;
  position: fixed;
  left: 50%;
  top: -100%;
  z-index: 11;
  width: 360px;
  -webkit-transform: translate(0, -500%);
  -ms-transform: translate(0, -500%);
  transform: translate(0, -500%);
  -webkit-transition: -webkit-transform 0.3s ease-out;
  -moz-transition: -moz-transform 0.3s ease-out;
  -o-transition: -o-transform 0.3s ease-out;
  transition: transform 0.3s ease-out;
}
.modal-body {
  padding: 20px;
}
.modal-header,
.modal-footer {
  padding: 10px 20px;
}
.modal-header {
  border-bottom: #eeeeee solid 1px;
}
.modal-header h2 {
  font-size: 20px;
}
.modal-footer {
  border-top: #eeeeee solid 1px;
  text-align: right;
}

EDIT:

Chrome Canary37+有dialog元素。更多信息在代码示例。其主要利润是show, close and showModal方法和::backdrop背景的 CSS 选择器。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

有没有 HTML5 替代 JS 的 Alert Box? 的相关文章

随机推荐

  • 通过 Angular 2 中的所有组件加载脚本

    我一直在使用 Angular 2AdminLTE需要运行一些脚本才能正确加载 所以我已将它们添加到我的 angular cli json scripts node modules jquery dist jquery min js node
  • 如何将 Grid 填充到 TextBlock 中?

    有一天 我遇到了以下 xaml 我吓坏了
  • k8s和微服务之间如何互相访问

    使用K8S部署 我们的项目基于springcloud 我想知道在K8S中 由于多节点部署通过registry的默认主机名 所以gateway部署在A config部署在B 之前他们是无法通过eureka互相访问的 我改为eureka ins
  • 将优惠券代码名称添加到 Woocommerce 查看订单详细信息和电子邮件通知

    我注意到在查看订单详细信息和电子邮件确认中 它反映了折扣线 但没有说明实际使用的折扣代码 此外 如果折扣代码为 0 00 美元 我们有时出于特殊跟踪目的而使用 0 美元代码 它甚至根本不会显示该代码 我花了一整天的时间试图找到解决方案 有人
  • 如何使用 Android 支持库 23.2 将 vectorDrawable 用作推送通知的图标? setSmallIcon 给出错误

    我的应用程序使用 API android defaultConfig vectorDrawables useSupportLibrary true 除了推送通知的图标外 所有视图都可以正常工作 NotificationCompat Buil
  • iText - 将内容添加到现有 PDF 文件

    我想用 iText 执行以下操作 1 解析现有的PDF文件 2 在文档的现有单页上添加一些数据 例如时间戳 3 写出文件 我似乎不知道如何使用 iText 来做到这一点 在伪代码中我会这样做 Document document reader
  • 如何在 iOS 8 中执行“actionSheet showFromRect”?

    在iOS 7中 我通过 showFromRect 显示actionSheet actionSheet showFromRect rect inView view animated YES 但在 iOS 8 中 这不起作用 他们替换了实现并建
  • Backbone.js:重新填充或重新创建视图?

    在我的 Web 应用程序中 左侧的表中有一个用户列表 右侧有一个用户详细信息窗格 当管理员单击表中的用户时 其详细信息应显示在右侧 我的左侧有一个 UserListView 和 UserRowView 右侧有一个 UserDetailVie
  • ASP.NET 成员身份角色 Web.config 设置

    我想了解 web config 上的 system web 授权标签如何工作 以及每个属性和属性的具体作用 例如 什么是
  • 在合并或推送之前强制功能分支重新建立基础

    在我们的项目中 我们有一个develop分支 我们有六名开发人员可以自由地推动开发 但我们要求他们在进行合并之前在开发之上重新调整其功能分支 有时 人们会忘记这样做 这会在开发过程中产生更丑陋的合并历史 git 中是否有一个配置设置 或者
  • 在现有路由的 rspec 测试中找不到路由

    耙路线显示 estimate location GET estimate location id format estimate location show 我的 rspec 测试 it should re direct to locati
  • 超时 SqlException 故障排除

    我有一些奇怪的行为 我无法弄清楚为什么会发生 我看到间歇性超时异常 我很确定它与体积有关 因为它在我们的开发环境中不可重现 作为一个创可贴解决方案 我尝试将 sql 命令超时增加到六十秒 但正如我发现的那样 这似乎没有帮助 这是奇怪的部分
  • 数据如何存储在磁盘上? - EFI GUID

    我早些时候发布了这个问题超级用户但我觉得它更适合程序员 如果我理解正确的话 根据 GPT LBA 2 的前 16 个字节是磁盘上第一个分区的分区类型 GUID 在 Windows 磁盘管理中 第一个分区被指定为 EFI 系统分区 然而 经过
  • Angular2 应用程序无法在 Microsoft Edge 上运行

    我的 angular2 应用程序无法在 Microsoft Edge 上运行 但在 Chrome 和 Firefox 上运行良好 我在看this问题 但这对我没有帮助 我在 Edge 控制台上收到以下错误 下面是package json文件
  • 查找 PIL / PILLOW 正在使用哪个 libjpeg

    我收到一个错误 在两台不同的计算机上读取相同的 lena jpg 文件会产生两个不同的校验和 更奇怪的是 当我运行 md5sum lena jpg 时 我在两台机器上得到相同的 md5 和 因此文件是相同的 此外 当我加载 png 而不是
  • 如何在 pytorch 中正确保存 torch.nn.Sequential 模型?

    我非常清楚加载字典 然后使用旧的参数字典加载一个实例 例如这个很棒的问题和答案 不幸的是 当我有一个torch nn Sequential我当然没有它的类定义 所以我想仔细检查一下 正确的方法是什么 我相信torch save就足够了 到目
  • 动态构建资源标识符

    我正在尝试使用动态获取资源 String stringarray res getStringArray R array XXXX 其中 XXXX 是变量 有什么建议么 谢谢 int resID getResources getIdentif
  • Android Studio 中带有自定义适配器的自定义 ListView

    我不知道有什么问题吗 没有任何错误 并且程序 工作完美 但是 当我单击列表视图中的某个项目时 它不会执行任何操作 换句话说 吐司 不会通过 这是我的主要课程 public class ViewListAct extends ActionBa
  • 为什么 CMake 不尊重 LIBRARY_PATH 和 CPATH

    我在使用模块的 HPC 系统上使用 CMake 这些模块通常设置LIBRARY PATH and CPATH因此 人们可以简单地包含标头并链接到库 而无需额外的操作 L or I 但是 当使用 CMake 时 CMake 必须找到这些库 我
  • 有没有 HTML5 替代 JS 的 Alert Box?

    有没有纯HTML5的选择到 JS 的警报框 我从未涉足过 JS 或其他脚本 代码 我只对 HTML5 和 CSS3 感到满意 我真的很喜欢语义 如果没有也没关系 好 奇多于需要 谢谢 杰西 HTML5是一个平台和品牌 它包括许多javasc