html - 为什么颜色没有显示在我的 CSS 中?如果我注释掉页脚的颜色,它确实会出现,但其余文本看起来像垃圾
问题描述
<footer id="footer">
<div id="footerRight">
<ul>
<li><a class="currentbottomnav" href="about.html">About</a></li>
<li><a href="store.html">Store</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div id="footerLeft">
<p>Follow us</p>
<ul>
<li><a href="#"><i class="fab fa-facebook"></i></a></li>
<li><a href="#"><i class="fab fa-twitter-square"></i></a></li>
<p>.........................</p>
</div>
</footer>
CSS------------------------------------------------ -
footer {
color:white;
position:absolute;
bottom:0;
width:100%;
height: auto;
background-color: rgba(255, 255, 255, 0.1);
padding: 15px;
box-sizing: border-box;/*Removes the extra width on the box*/
border-radius: 50% 50% 0 0 / 5%;
}
footer #footerLeft a{
font-size:25px;
text-decoration: none;
color: whitesmoke;
}
footer #footerRight a{
text-decoration: none;
color: whitesmoke;
margin:10px;
}
.currentbottomnav {
color: aqua;
}
footer ul {
list-style: none;
}
footer li {
display:inline-block;
}
footer #footerRight a:hover{
color: rgb(90 90 90);
font-weight: 300;
transition-duration: 0.4s;
}
footer #footerLeft a:hover{
color: rgb(90 90 90);
font-weight: 300;
transition-duration: 0.4s;
}
#footerRight{
float:right;
}
#footerLeft{
float: left;
}
我说的是“页脚#footerRight a{...}”,一个。如果我在那里注释掉 whitesmoke,第一个元素的颜色会按照它的意图弹出(这就是我想要的),但其余元素不再漂亮,因为它们不再使用 whitesmoke 定制。
我正在尝试更改页脚和页眉链接中快速链接的颜色。我得到了用于页眉链接的那些,但现在当我尝试为页脚做那些时,它不起作用。我正在使用一个类来改变颜色。
解决方案
由于您在 CSS 中使用了 ID,因此未显示浅绿色。ID 优先于类名的任何标准使用。
所以.currentbottomnav
被footer #footerRight a
快速解决您的问题的方法是更改为footer #footerRight .currentbottomnav
.
然而,问题的症结在于使用 ID 来挂钩样式。而是为每个元素创建一个类并使用它们。ID 非常适合为 javascript 等提供独特的钩子以供使用,但在 CSS 中,除非绝对必要,否则最好避免使用它们。
推荐阅读
- kotlin - Kotlin 中相同的属性名称和主构造函数参数名称
- amazon-web-services - CloudFormation - 在禁用状态下创建 SNS 订阅
- c# - 为什么使用 ToListAsync 没有结果?
- python - 使用 SSHTunnelForwarder 功能 - 基于方式来保持连接?
- asp.net-mvc - 在中继器内部使用
- eclipse - 在 Eclipse 中引用外部文件:虚拟链接文件与项目属性中的构建设置?
- angular - 手动传递的 Angular 路由变量在组件中未定义
- android - Android 支持库文件夹没有更新版本
- python - NLP 分类器 - Python 太多的值无法解包
- reactjs - 在 React JS 中以编程方式重定向子组件内部不起作用