简体   繁体   English

如何使用 CSS 将默认 Bootstrap 按钮颜色更改为我自己选择的自定义颜色?

[英]How can i change the default Bootstrap button color to my own choice of custom color by using CSS?

 .nav-link { font-family: "Montserrat"; font-weight: 300; font-size: 1.2rem; color: #ededed; }
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/> <li class="nav-item"> <a class="nav-link" href="#about">about</a> </li>

Every other element in the css part is working except the color element.除了颜色元素之外,css 部分中的所有其他元素都在工作。 When i inspected the webpage in chrome developer tool, It showed that the css is not overriding the default bootstrap button color (rgba).当我在 chrome 开发者工具中检查网页时,它表明 css 没有覆盖默认的引导按钮颜色(rgba)。

First add a new class to your element, then over writing bootstrap styles using important首先向您的元素添加一个新类,然后使用important覆盖引导样式

 .nav-link { font-family: "Montserrat"; font-weight: 300; font-size: 1.2rem; color: #ededed; } .new-class{ /* over write */ color:red !important; font-size:30px !important; /* etc */ } .new-class:hover{ color:#000 !important; } .il-style { list-style:none !important; }
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/> <li class="nav-item il-style"> <a class="nav-link new-class" href="#about">about</a> </li>

  • Or u can call your style.css after bootstrap style without using important , but sometime you need to use it.或者你可以在bootstrap 样式之后调用你的style.css而不使用important ,但有时你需要使用它。

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

相关问题 使用Bootstrap时如何改变身体的颜色? - How can I change the color of my body when using Bootstrap? 如何在实现CSS中更改默认按钮的颜色? - How to change default button color in materialize css? 我正在使用引导程序如何使用我的 css 文件更改此导航栏的颜色? - I am using bootstrap how do I change the color of this navbar by using my css file? CSS:如何更改引导程序导航栏背景色 - CSS: How can I change bootstrap navigation bar background color 如何更改我的边框颜色<select>元素不影响引导 css 样式? - How can I change the border color on my <select> element without effecting bootstrap css styling? 仅当单击CSS时,如何才能更改按钮的颜色? - How can I change the color of a button with CSS only when it is clicked? 当 ion-tab-button 处于活动状态时,如何更改图标的颜色? CSS 离子 - How can i change the color of my icon when ion-tab-button is active? CSS Ionic 如果使用CSS悬停,如何使我的禁用按钮不会改变颜色? - How can I make my disabled button not change color when there's a hover with CSS? 如何更改w3.css按钮自己的颜色? - How to change w3.css button's own color? CSS按钮,默认颜色,悬停颜色和:active颜色更改 - CSS Button, default color, hover color and :active color change
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM