CSS space before selector

前端 未结 2 1529
Happy的楠姐
Happy的楠姐 2020-12-07 04:30

I was struggling to understand why this simple CSS class selector was not being picked by my HTML element.

.label-hi :before {
    color:green;
    content:          


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 04:38

    So I realized that for this specific selectors I cannot have any space between the class name and the : This means that removing the empty space my CSS class is picked :

    .label-hi:before {
        color:green;
        content: "Hi ! ";
    }
    

    In regular classes that space does not make any difference.

    Sample here : http://jsfiddle.net/GtTcn/

提交回复
热议问题