CodePen示例:http://codepen.io/haoyuchen1992/pen/XXXMZK
HTML CODE:
<li class = "test" profile="url(http://design.ubuntu.com/wp-content/uploads/ubuntu-logo32.png)" contentDis = "contentDis">
This is bad!
</li>
CSS代码:
.test:before {
right: -80px;
background-size:cover;
content: attr(contentDis);
background-image: attr(profile);
}
我不知道为什么attr
函数在内容属性中有效。但是对于background-image
,配置文件字符串不能正确应用。
---找到解决方案!! ---
https://developer.mozilla.org/en-US/docs/Web/CSS/attr
attr()函数可以与任何
CSS
属性一起使用,但对内容以外的属性的支持是实验性的。
主流浏览器仍然不支持其他属性。