Igu
Igu

Reputation: 35

Change font color inside nav

Hello I'm a newcomer and I want to change the color of the font inside the navbar but cant find any solution, here is the code:

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">testteee</a>
    </div>
    <ul class="nav navbar-nav navbar-right">
      <li class="active"><a href="#">About</a></li>
      <li><a href="#">Portofolio</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </div>
</nav>
<main>
  <header>
    <p>teste</p>
  </header>
</main>

CSS:

body {
  background-color: grey;
}
.navbar {
  background-color: purple;
  border: transparent;
  box-shadow: 0px 0px 0px 2px grey;
  margin: 0;
}
main {
  width: 60%;
  background-color: white;
  margin: 0 auto;
  box-shadow: 0.5px 0.5px 0.5px 0.5px grey;
}

Any additional tips would be great for my development :)

Upvotes: 1

Views: 1768

Answers (4)

zalog
zalog

Reputation: 723

This might be what you need, but I'd suggest you to to change this from sass/scss variables. It might be a long way because you have to learn how to build bootstrap css files in a nodejs environment, this can help.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <style>
        body {
          background-color: grey;
        }
        .navbar-custom {
          background-color: purple;
          border: transparent;
          box-shadow: 0px 0px 0px 2px grey;
          margin: 0;
        }
        .navbar-custom .navbar-header a,
        .navbar-custom .navbar-header a:hover {
          color: #fff;
        }
        .navbar-custom ul.navbar-nav li a:hover {
          background-color: gray;
          color: #fff;
        }
        .navbar-custom ul.navbar-nav a {
          color: #fff;
        }
        .navbar-custom ul.navbar-nav a:hover {
          color: blue;
        }

        main {
          width: 60%;
          background-color: white;
          margin: 0 auto;
          box-shadow: 0.5px 0.5px 0.5px 0.5px grey;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">Logo</a>
    </div>
    <ul class="nav navbar-nav navbar-right">
      <li class="active"><a href="#">About</a></li>
      <li><a href="#">Portofolio</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </div>
</nav>
<main>
  <p>main content</p>
</main>
</body>
</html>

Also, I think it's a bad practice and it's not scalable to use !important.

You can read something about when to use important and perhaps some css specificity :)

Upvotes: 1

Jonny
Jonny

Reputation: 1329

Use color in CSS to change a fonts color.

.navbar {
background-color: purple;
border: transparent;
box-shadow: 0px 0px 0px 2px grey;
margin: 0;

}

a{color:red;}

If you are using a framework and need it to change use !important. !important changes a style that was already set.

.navbar {
background-color: purple;
border: transparent;
box-shadow: 0px 0px 0px 2px grey;
margin: 0;

}

a{color:red!important;}

Upvotes: 1

RickD
RickD

Reputation: 79

You can append color to the navbar class like so color: #whatevercoloryouchoose

it should look like this

.navbar {
 color: #whatevercoloryoulike;
 background-color: purple;
 border: transparent;
 box-shadow: 0px 0px 0px 2px grey;
 margin: 0;
}

Upvotes: 0

Keoki
Keoki

Reputation: 304

You can add font color to your nav css {color: #fff} or if you just want to change the text color of your links then .navbar a {color: #fff} for example. You can do the same for all variations of links .navbar a, .navbar a:hover, .navbar a:visited {color: #fff}

Upvotes: 0

Related Questions