为什么我的以"#"开头的没有变色,只有以"#-"开头的变色。
为什么我的以"#"开头的没有变色,只有以"#-"开头的变色。
我用的是360极速浏览器chrome的内核。代码如下。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Attribute</title>
<style type="text/css">
a[href]{
text-decoration: none;
}
a[href|="#"]{
color: #f0f;
}
</style>
</head>
<body>
<a href="attribute.html">attribute</a>
<a href="#">attribute</a>
<a class="one two" href="#1">attribute</a>
<a class="two three" href="#2">attribute</a>
<a href="#3">attribute</a>
<a href="#4">attribute</a>
<a href="#5">attribute</a>
<a href="#6">attribute</a>
<a href="3#">attribute</a>
<a href="4#">attribute</a>
<a href="5#">attribute</a>
<a href="6#">attribute</a>
<a href="3#3">attribute</a>
<a href="4#4">attribute</a>
<a href="5#5">attribute</a>
<a href="6#6">attribute</a>
<a href="#-3">attribute</a>
<a href="#-4">attribute</a>
<a href="#-5">attribute</a>
<a href="#-6">attribute</a>
</body>
</html>
正在回答 回答被采纳积分+1
[href|="#"]是包含只有#或#-开头的会变色
[href|="#"] 你这么写就是以#-开头的变色啊 你没好好听课啊 [href^="#"] 这么写才是以#开头的
- 参与学习 1887 人
- 提交作业 4643 份
- 解答问题 5760 个
有HTML和CSS基础,却不知道如何进阶?本路径带你通过系统学习,完成从“会做网页”到“做出好的动态网页”的蜕变,迈出成为前端工程师的第一步。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星