html - 多个 CSS 模态框

标签 html css modal-dialog

所以我正在阅读以下文章: Create Modal window with CSS3

但是,我想通过向我的网站添加多个模式框来修改它。

这是原始模态的代码:

<a href="#openModal">Open Modal</a>

<div id="openModal" class="modalDialog">
    <div>
        <a href="#close" title="Close" class="close">X</a>
    <h2>Modal Box</h2>
    <p>This is a sample modal box that can be created using the powers of CSS3.</p>
    <p>etc..etc..</p>
</div>

<div id=openModal" 没有 CSS 调用 要创建多个模式,我的假设是将 div 更改为 <div id=openModal2" class="modalDialog2">

样式仅在模态对话框上,因此对于第二个模态,我假设我也会更改它的类名。

但是,每次我这样做,它都不会打开模态框。

这是我的代码:

<a href="#openModal1">Box 1</a>

<div id="openModal1" class="modalDialog1">
<div>
    <a href="#close" title="Close" class="close">X</a>
    <h2>Modal Box 1</h2>
    <p>This is a sample modal box that can be created using the powers of CSS3.    </p>
    <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
</div>
</div>
<a href="#openModal2">Box 2</a>

  <div id="openModal2" class="modalDialog2">
<div>
    <a href="#close" title="Close" class="close">X</a>
    <h2>Modal Box 2</h2>
    <p><strong>Box 2</strong></p>
    <p>yadda yadda</p>
</div>

我在这里做错了什么?

最佳答案

您不必更改类(class)。类的作用是将相同的样式应用于不同的元素,因此保留它 modalDialog 就可以完成这项工作。

演示: http://jsfiddle.net/3Vykc/

关于html - 多个 CSS 模态框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13887496/

相关文章:

html - 在 Firefox 上渲染 Open Sans Light 时出现问题

html - 如何在两列下拉菜单中显示子菜单

jquery - 出现错误 Uncaught ReferenceError : BootstrapDialog is not defined

html - CSS :before not working in IE11

javascript - 获取上传图像的宽度(在将文件上传到服务器之前)

ASP.NET 3.5 自定义 DataPager

css - 用覆盖 mask div,防止 mask 滚动

javascript - jquery geocomplete 无法与 vue js 一起使用

jquery - 将 HTML 数据属性传递给语义 UI 模式

html - Google 爬虫的标签是否有任何元数据属性