css - 选择图像的问题
问题描述
很抱歉这个问题很简单。这无论如何都不起作用,我不知道还能做什么。
不应该选择这个图像?我尝试了很多方法来选择它,但它没有被选中。
我可能犯了一个愚蠢的错误。
HTML
<div class="social-media__banner">
<ul>
<li>
<a href="">
<img id="icon-test" src="images/github.svg" alt="github">
</a>
</li>
<li>
<a href="">
</a>
</li>
<li>
<a href="">
</a>
</li>
</ul>
</div>
CSS
.social-media__banner {
margin-top: 20px;
position: absolute;
top:500px;
left: 0;
width: 100%;
height: 200px;
ul{
left: 0rem;
width: 30px;
display: flex;
padding: 0;
li{
margin: 0 10px;
list-style: none;
font-size: 20px;
padding: 20px 20px;
color: white;
a{
position: relative;
display: block;
width: 50px;
height: 50px;
background-color: white;
color: black;
text-align: center;
border-radius: 50%;
overflow: hidden;
}
}
}
}
#icon-test{
height: 24px;
margin-top: 11px;
}
*我检查了检查器工具,它甚至没有选择。
谢谢
解决方案
如果不是为了清洁,为什么要嵌套所有这些选择器?坚持基础,你就不会出错。您无需.social-media__banner
在代码中编写几次即可。
.social-media__banner {
margin-top: 20px;
position: absolute;
top:500px;
left: 0;
width: 100%;
height: 200px;
}
.social-media__banner ul{
left: 0rem;
width: 30px;
display: flex;
padding: 0;
}
.social-media__banner li{
margin: 0 10px;
list-style: none;
font-size: 20px;
padding: 20px 20px;
color: white;
}
.social-media__banner a{
position: relative;
display: block;
width: 50px;
height: 50px;
background-color: white;
color: black;
text-align: center;
border-radius: 50%;
overflow: hidden;
}
#icon-test{
height: 24px;
margin-top: 11px;
}
<div class="social-media__banner">
<ul>
<li>
<a href="">
<img id="icon-test" src="https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg" alt="github">
</a>
</li>
<li>
<a href="">
</a>
</li>
<li>
<a href="">
</a>
</li>
</ul>
</div>
推荐阅读
- if-statement - 这是关于 Else/If 函数的开始问题
- modelica - Modelica - 在模拟期间冻结特定时间值
- graph-theory - 需要哪些索引信息来快速检查有向无环图的节点是否在另一个节点之前、之后或平行?
- github - 为什么 apt-get 在 Ubuntu 18.04 版本上找不到 github-ee 包?
- ruby - 哈希中具有多个值的重复值的总和
- java - 是否可以在 close() 之后重新打开文件而不在同一个 java 程序中再次创建它?
- javascript - 在 Angular 7、Jasmine、Karma、Chrome 中测试 HTMLMediaElement.play()
- config - Zookeeper:zookeeper可以支持多少个节点?
- python - 如何使用 GridSearchCV 和 sklearn Pipeline 用训练数据的估算值估算测试数据
- java - Mac 上的 Eclipse 抛出错误“java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException”