css不能正常工作,具体取决于顺序。任何人都可以在这里解释订单如何影响代码

时间:2018-07-23 13:09:30

标签: css

我正在借助此链接制作弹出窗口 https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_popup 但是我通过将以下代码行放在样式表的开头来更改了CSS的顺序

`.popup .show {
    visibility: visible;
    -webkit-animation: fadeIn 1s;
    animation: fadeIn 1s;
    }
`

,弹出窗口的可见性属性停止更改,在开发人员工具中,我可以看到visibility : visible属性已被取消。我在下面的代码中使用了确切的顺序,如下所示,该顺序不起作用,但是当我在共享链接中遵循该顺序时,它便开始起作用

     <style>
     /* Toggle this class - hide and show the popup */
    .popup .show {
    visibility: visible;
    -webkit-animation: fadeIn 1s;
    animation: fadeIn 1s;
    }

    /* Add animation (fade in the popup) */
    @-webkit-keyframes fadeIn {
    from {opacity: 0;} 
    to {opacity: 1;}
    }

    @keyframes fadeIn {
    from {opacity: 0;}
    to {opacity:1 ;} 
    }

    /* Popup container - can be anything you want */
    .popup {
    position: relative;
    display: inline-block;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    }

    /* The actual popup */
    .popup .popuptext {
    visibility: hidden;
    width: 160px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -80px;
    }

    /* Popup arrow */
   .popup .popuptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
    }
 </style>

0 个答案:

没有答案