简体   繁体   English

为什么我的 css 只应用了 div 的一半

[英]Why is my css applying only half of the div

Why is half of my css code working only on half of the div?为什么我的 css 代码的一半只在 div 的一半上工作? this is my code这是我的代码

 #cardleft h1{ margin-top: 25px; text-align: center; font-size: 40px; line-height: 40px; position: relative; left: 0px; } #cardleft{ border: 2px solid #68C3A3; margin-right: 10px; border-radius: 30px 0px 0px 30px ; color: #4aa0c2 !important; } #cardleft:hover{ background-color: #4eb28f; color: gold !important; }
 <div id="cardleft" class="col-md-4 "> <div class="col-md-3"> <i class="fab fa-linkedin fa-6x"></i> </div> <h1>LinkedIn</h1> </div>

I tried multiple ways on doing this, I still am getting same issues.我尝试了多种方法来执行此操作,但仍然遇到相同的问题。 tried adding !important but nothing seems to change.尝试添加!important但似乎没有任何改变。

but weirdly enough the same code works in codepen.io但奇怪的是,相同的代码在 codepen.io 中有效

am I doing something wrong in the IDE?我在 IDE 中做错了什么吗? I'm using visual studio code我正在使用 Visual Studio 代码

 #cardleft h1{ margin-top: 25px; text-align: center; font-size: 40px; line-height: 40px; position: relative; left: 0px; } #cardleft h1, #cardleft i{ color: #4aa0c2; } #cardleft{ border: 2px solid #68C3A3; margin-right: 10px; border-radius: 30px 0px 0px 30px ; } #cardleft:hover{ background-color: #4eb28f; } #cardleft:hover h1, #cardleft:hover i{ color: gold !important; }
 <div id="cardleft" class="col-md-4 "> <div class="col-md-3"> <i class="fab fa-linkedin fa-6x"></i> </div> <h1>LinkedIn</h1> </div>

You need to add color style to h1 tag.您需要为h1标签添加颜色样式。

Maybe you just have to create unique names for the css classes in this HTML file?也许您只需要为这个 HTML 文件中的 css 类创建唯一的名称? Sounds like the text color is being overwritten somewhere else because of class names.听起来像文本颜色因为类名而在其他地方被覆盖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM