css:target不适用于mozilla firefox

时间:2014-10-03 10:33:39

标签: html css wordpress

我正在尝试在css上使用':target'命令在我的wordpress网站上显示一个模态。它使用chrome浏览器工作正常,但如果我使用mozilla它不起作用。当whet':target'被激活时,我只需要将'opacity'属性更改为1。 这是我正在使用的'css':

    .modalDialog {
    position: fixed;
    font-family: Arial, Helvetica, sans-serif;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,0.8);
    z-index: 99999;
    opacity:0;
    -webkit-transition: opacity 400ms ease-in;
    -moz-transition: opacity 400ms ease-in;
    transition: opacity 400ms ease-in;
    pointer-events: none;
}



.modalDialog:target {
    opacity:1;
    pointer-events: auto;
}

感谢大家的帮助。

1 个答案:

答案 0 :(得分:1)

此示例适用于mozilla firefox DEMO

<强> HTML:

<ul>
    <li><a href="#h1">link 1</a></li>
    <li><a href="#h2">link 2</a></li>
  </ul>
  <h2 id="h1">link 1</h2>
   <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero eligendi, incidunt harum laborum ratione, labore quae modi hic est sint, aperiam corporis nesciunt dolor quasi iusto eaque itaque. Modi, deleniti.</p>
  <h2 id="h2">link 2</h2>
   <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint voluptates quia culpa, quos facilis, dicta reiciendis impedit deserunt a distinctio corporis in eos ipsum provident cum, dolorum dolorem tempore sapiente.</p>
</ul>

<强> CSS:

h2:target {
    background: #fc0; /* Цвет фона */
    padding: 3px; 
}