简体   繁体   English

如何从默认的蓝色更改 CSS 中这些链接的颜色?

[英]How do I change the color of theses links in CSS from the default blue?

I have put the style text-decoration: none; color: black;我已经把样式text-decoration: none; color: black; text-decoration: none; color: black; but it does not seem to be applying.但它似乎并不适用。 I look on the inspection tab and it's showing that it's applied but the text does not change.我查看检查选项卡,它显示它已应用但文本没有更改。

 .Bottom-Grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(1, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; height: 150px; width: auto; text-transform: capitalize; font-size: 15px; font-family: GT Pressura Mono, Roboto Mono, monospace; } .List-Five, .List-Six, .List-Seven, .List-Eight, .link-1 { list-style-type: none; text-decoration: none; color: black; }
 <div class="Bottom-Grid"> <div class="five"> <ul class="List-Five"> <li class="link-1"><a href="#">all</a></li> <li class="link-2"><a href="#">Tea</a></li> <li class="link-3"><a href="#">Merch</a></li> <li class="link-4"><a href="#">Brew Wares</a></li> </ul> </div> <div class="six"> <ul class="List-Six"> <li class="link-5"><a href="#">Wholesale</a></li> <li class="link-6"><a href="#">About Us</a></li> <li class="link-7"><a href="#">Contact</a></li> <li><a href="#">FAQs</a></li> </ul> </div> <div class="seven"> <ul class="List-Seven"> <li class="link-8"><a href="#">my orders</a></li> <li class="link-9"><a href="#">sign up</a></li> </ul> </div> <div class="eight"> <ul class="List-Eight"> <li class="link-9"><a href="#">terms & conditions</a></li> <li class="link-10"><a href="#">privacy Policy</a></li> </ul> </div> </div>

As you can see, the style is applied but the links are still that default blue.如您所见,样式已应用,但链接仍为默认蓝色。

You are applying the styles to li not a您正在将样式应用于lia

There is 2 solutions for you:有2个解决方案供您使用:

Solution 1 - add a to the selector of each rule解决方案 1 - 在每个规则的选择器中添加a

 .Bottom-Grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(1, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; height: 150px; width: auto; text-transform: capitalize; font-size: 15px; font-family: GT Pressura Mono, Roboto Mono, monospace; } .List-Five a, .List-Six a, .List-Seven a, .List-Eight a, .link-1 a { list-style-type: none; text-decoration: none; color: black; }
 <div class="Bottom-Grid"> <div class="five"> <ul class="List-Five"> <li class="link-1"><a href="#">all</a></li> <li class="link-2"><a href="#">Tea</a></li> <li class="link-3"><a href="#">Merch</a></li> <li class="link-4"><a href="#">Brew Wares</a></li> </ul> </div> <div class="six"> <ul class="List-Six"> <li class="link-5"><a href="#">Wholesale</a></li> <li class="link-6"><a href="#">About Us</a></li> <li class="link-7"><a href="#">Contact</a></li> <li><a href="#">FAQs</a></li> </ul> </div> <div class="seven"> <ul class="List-Seven"> <li class="link-8"><a href="#">my orders</a></li> <li class="link-9"><a href="#">sign up</a></li> </ul> </div> <div class="eight"> <ul class="List-Eight"> <li class="link-9"><a href="#">terms & conditions</a></li> <li class="link-10"><a href="#">privacy Policy</a></li> </ul> </div> </div>

Solution 2 - inherit properties解决方案 2 - 继承属性

 .Bottom-Grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(1, 1fr); grid-column-gap: 0px; grid-row-gap: 0px; height: 150px; width: auto; text-transform: capitalize; font-size: 15px; font-family: GT Pressura Mono, Roboto Mono, monospace; } .List-Five, .List-Six, .List-Seven, .List-Eight, .link-1 { list-style-type: none; text-decoration: none; color: black; } .Bottom-Grid a { color: inherit; text-decoration: inherit }
 <div class="Bottom-Grid"> <div class="five"> <ul class="List-Five"> <li class="link-1"><a href="#">all</a></li> <li class="link-2"><a href="#">Tea</a></li> <li class="link-3"><a href="#">Merch</a></li> <li class="link-4"><a href="#">Brew Wares</a></li> </ul> </div> <div class="six"> <ul class="List-Six"> <li class="link-5"><a href="#">Wholesale</a></li> <li class="link-6"><a href="#">About Us</a></li> <li class="link-7"><a href="#">Contact</a></li> <li><a href="#">FAQs</a></li> </ul> </div> <div class="seven"> <ul class="List-Seven"> <li class="link-8"><a href="#">my orders</a></li> <li class="link-9"><a href="#">sign up</a></li> </ul> </div> <div class="eight"> <ul class="List-Eight"> <li class="link-9"><a href="#">terms & conditions</a></li> <li class="link-10"><a href="#">privacy Policy</a></li> </ul> </div> </div>

.List-Five, .List-Six, .List-Seven, .List-Eight, .link-1>a{
      list-style-type: none;
      text-decoration: none;
      color: black;
   }

This works fine, you have to actually apply the styling to the <a> tag.这很好用,您必须将样式实际应用于<a>标记。

You can also apply the inherit styling on the <a> tag.您还可以在<a>标记上应用继承样式。 This will then copy the styling for color, for example if you were to say: color: inherit;然后,这将复制颜色的样式,例如,如果您要说: color: inherit;

https://codepen.io/SuperHydroMan/pen/eYVqzGo https://codepen.io/SuperHydroMan/pen/eYVqzGo

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

相关问题 如何更改选择列表中的默认蓝色 - How I can change the default blue color in select list 如何使用CSS从图像更改蓝色背景选择颜色 - How to Change blue background selection color from image using css 如何在不使用materilaize中的自定义CSS的情况下将默认主题颜色teal更改为蓝色 - How to change default theme color teal to blue without using custom CSS in materilaize 如何将html中下拉菜单的默认高亮颜色从蓝色更改为其他颜色<select><option>标签 - How to change the default highlight color of drop down in html from blue to some other color for <select><option> tag 无法将导航药丸的默认背景颜色从蓝色更改 - Unable to change nav-pills default background color from blue 如何根据背景中的内容从 NAV-Links 更改“颜色”CSS 属性? - How can I change the “Color” CSS Attribute from NAV-Links depending on what is in the background? 如何将此按钮的背景从蓝色更改为橙色? - How do I change the background of this button from blue to orange? 如何更改 CSS 中变量的颜色? - How do I change the color of a variable in CSS? 如何在CSS中更改NavBar颜色 - How do I change NavBar Color in CSS 如何使用 function 在 HTML 中将绿色鹦鹉图片的颜色更改为蓝色鹦鹉图片? - How do I change the color of the green parakeet picture to a blue parakeet picture in HTML using a function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM