gpt4 book ai didi

css - 为什么我的伪类覆盖显示 :none?

转载 作者:太空宇宙 更新时间:2023-11-04 01:36:39 24 4
gpt4 key购买 nike

我有一个显示为“X”的 div(用于关闭窗口):

<div class="alertwrapper" style="display:inline-block;">
<div class="obj"></div>
<div class="x"></div> //<-----ELEMENT IN QUESTION
</div>

以下是该元素的 CSS 属性:

.x {
display: none !important;
position: absolute !important;
left:0;
top:0;
transition: transform .25s ease-in-out;
z-index:999;
}

.x:before {
content: "";
position: absolute;
//Here, I've also tried display:none !important;
left: 48%;
margin-left:-495px;
right: 0;
top: 115px;
bottom: 0;
width: 32px;
height: 0;
border-top: 3px solid black;
transform: rotate(45deg);
transform-origin: center;
z-index:999;
}
.x:after {
content: "";
position: absolute;
//Here, I've also tried display:none !important;
left: 48%;
margin-left:-495px;
right: 0;
top: 115px;
bottom: 0;
width: 32px;
height: 0;
border-top: 3px solid black;
transform: rotate(-45deg);
transform-origin: center;
z-index:999;
}

在单击另一个元素之前不应显示此 div,此时它应该出现,如以下代码所定义:

<script type="text/javascript">
$(document).ready(function () {
$('body').on('click', '.ActiveQuestionCycler', function() {
$("div.x").fadeIn(300).delay(1500);
$("div.obj").fadeIn(300).delay(1500);
});
});
</script>

但是,当页面加载时,在单击 .ActiveQuestionCycler 之前,div“x”是可见的。 (显示未设置为无。)我认为这与覆盖它的伪类 beforeafter 有关,但我不明白为什么。

(div.obj 在点击 .ActiveQuestionCycler 时会淡入。)

源中没有错误警报。

最佳答案

第 109 行的评论 ///STYLE SETTINGS FOR THE QUESTION CONTAINER AND CLOSE "X"BUTTON 无效。将其更改为:

/* 问题容器和关闭“X”按钮的样式设置 */

它应该可以工作。请记住将 display: none; 放入 .x

所以它看起来像:

.x {
display: none;
/* your other styles */
}

虽然 //comment 对于大多数编程语言来说是正常的,但常规的 css 不接受它并且 css 注释像这样 /* comment */

关于css - 为什么我的伪类覆盖显示 :none?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46105395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com