Attr函数不会用string实现

时间:2017-10-26 17:59:08

标签: css

我正在尝试使用attr

创建一个检查html图标文件的列表
li .school-list {
  position: relative;
  display:block;
}

.school-list::before {
    content: attr(icon string,"hello");
    display:block;
    background-repeat: no-repeat;
    background-size: cover;
    width: 10px;
    height:10px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

目前我只是想在内容中显示值,但如果我使用“string”作为值类型,它会100%失败。我究竟做错了什么?

这是我现在正在使用的HTML

<li icon='helloooo' class='school-list'><a href="https://www.sdbor.edu/administrative-offices/human-resources/Pages/default.aspx">Board of Regents-Pierre/Sioux Falls/ThisTestSpot</a></li>
<li icon='helloooo' class='school-list'><a href="http://www.bhsu.edu/FacultyStaff/HumanResources/tabid/867/Default.aspx">Black Hills State University-Spearfish</a></li>
<li icon='helloooo' class='school-list'><a href="http://dsu.edu/jobs">Dakota State University-Madison</a></li>
<li icon='helloooo' class='school-list'><a href="http://northern.edu/about/departments-and-offices/human-resources">Northern State University-Aberdeen</a></li>
<li icon='helloooo' class='school-list'><a href="http://www.sdsmt.edu/Campus-Services/Human-Resources/">South Dakota School of Mines &amp; Technology-Rapid City</a></li>
<li icon='helloooo' class='school-list'><a href="https://www.sdstate.edu/human-resources">South Dakota State University-Brookings</a></li>
<li icon='helloooo' class='school-list'><a href="http://www.usd.edu/hr/">University of South Dakota-Vermillion</a></li>

0 个答案:

没有答案