2017-06-02 91 views
0

該模式在內容注入頁面之前已經存在,但它不可見,請問您可以提出什麼問題?僞元素存在但不可見

.aloha { 
 
    font-family: Medium; 
 
    font-size: 74px; 
 
    color: green; 
 
    position: relative; 
 
    display: inline-block; 
 
    margin: 0; 
 
    height: 85px; 
 

 
    
 
} 
 

 
.aloha:before { 
 
    width: 100%; 
 
    height: 85px; 
 
    color: red; 
 
    content: attr(data-text); 
 
    display: block; 
 
}
<h1 date-text='TEXT' class='aloha'>TEXT</h1>

+0

由於這是一個簡單的拼寫錯誤,我建議刪除這個問題,因爲它沒有價值,未來用戶 – LGSon

回答

3

。在你的HTML一個錯字。您<h1>元素替換date-textdata-text

.aloha { 
 
    font-family: Medium; 
 
    font-size: 74px; 
 
    color: green; 
 
    position: relative; 
 
    display: inline-block; 
 
    margin: 0; 
 
    height: 85px; 
 
} 
 
.aloha:before { 
 
    width: 100%; 
 
    height: 85px; 
 
    color: red; 
 
    content: attr(data-text); 
 
    display: block; 
 
}
<h1 data-text='TEXT' class='aloha'>TEXT</h1>

+2

國旗收爲題外話,由於對錯字 – j08691

+0

謝謝塞巴斯蒂安,下次將更多關注:) – volna

+0

@ j08691 - 只是爲了信息:是在這種情況下的答案好,或者我應該只標記和評論? (我標記) –