[英]Button text color is not changing to white in SCSS code
我正在 codepen 鏈接上練習我的 CSS(SCSS): https ://codepen.io/zubaer41/pen/XWKzomo?editors = 1100 但我遇到了一個問題,無法修復它。 應該出現兩個按鈕,其中的文本應該是白色的。 我可以更改按鈕的背景顏色,但我無法將按鈕文本顏色設置為白色,即使我找不到任何原因。 請幫忙 !!
//==== HTML & CSS(SCSS) 代碼 ====
<nav >
<ul class="navigation">
<li><a href="#">About us</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="button">
<a class="btn-main" href="#">Sign up</a>
<a class="btn-hot" href="#">Get a quote</a>
</div>
</nav>```
=========================================================
=================== CSS (SCSS) CODE =====================
=========================================================
```* {
margin: 0;
padding: 0;
}
$color-primary: #f9ed69; //yellow color
$color-secondary: #f08a5d; //orange color
$color-tertiary: #b83b5e; //pink color
$color-text-dark: #333;
$color-text-light: #eee;
$width-button: 150px;
@mixin clearfix {
&::after {
content: "";
clear: both;
display: table;
}
}
@mixin style-link-text($color) {
text-decoration: none;
text-transform: uppercase;
color: $color;
}
@function divide($a, $b) {
@return $a / $b;
}
nav {
margin: divide(60, 2) * 1px;
background-color: $color-primary;
@include clearfix;
}
.navigation {
list-style: none;
float: left;
li {
display: inline-block;
margin-left: 30px;
margin-top: 10px;
&:first-child {
margin: 10px;
}
a {
@include style-link-text($color-text-dark);
}
}
}
.button {
float: right;
}
%btn-placeholder {
padding: 10px;
display: inline-block;
text-align: center;
border-radius: 100px;
width: $width-button;
@include style-link-text($color-text-light);
}
.btn-main {
&:link {
@extend %btn-placeholder;
background-color: $color-secondary;
}
&:hover {
background-color: darken($color-secondary, 10%);
}
}
.btn-hot {
&:link {
@extend %btn-placeholder;
background-color: $color-tertiary;
}
&:hover {
background-color: lighten($color-tertiary, 10%);
}
}```
我想你必須添加
&:focus { color:white; }
在您的.btn-main
和btn-hot
。 這使我的按鈕文本變成白色...
.btn-main {
&:link {
@extend %btn-placeholder;
background-color: $color-secondary;
color : #fff;
}
}
試試這個
定位 .button div 中的 'a',:link 僅在它是鏈接時才有效(設置了 href)
.button { a { color:#eee; } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.