我有顯示爲「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>
頁面加載,但是,格「x」是可見的,在點擊.ActiveQuestionCycler
之前。 (顯示不是沒有設置。)我認爲這與僞類before
和after
重寫了這一點,但我不明白爲什麼。
(div.obj
被點擊時.ActiveQuestionCycler
DOES淡入。)
有在源沒有錯誤警報。
Snoops,是否有代碼在任何地方的工作示例,如代碼項目,codepen或jsfiddle? – cwanjt
我會做一個簡單的JSFiddle瞬間 – Snoops
爲什麼你有這麼多的風格標籤?我會將它們整合到一個樣式表中 –