2017-06-02 52 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 - 只是为了信息:是在这种情况下的答案好,或者我应该只标记和评论? (我标记) –