Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Raymond Tran
6,285 PointsHow to customize CSS of Bootstrap 4 elements?
<ul class="nav nav-pills nav-stacked hidden-md-up ">
<li class="nav-item active ">
<a class="nav-link active " href="#">Home </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Shipping</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
Link to my work ( adjust to the smaller window to see the stacked nav) : link
2 Answers
John Steer-Fowler
Courses Plus Student 11,734 PointsHi Raymond,
You can either go into the original CSS file for bootstrap 4, find the selector you want and adjust the original css there.
Or, you can use the selectors in your own css file eg:
.nav-item {
background-color: #000;
}
If you use this second option, make sure the link to the css file comes above the link to the bootstrap css file
<!-- style.css needs to come before the bootstrap css -->
<link rel="stylesheet" type="text/css" href="style/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
Hope this helps
Raymond Tran
6,285 PointsHi John, For second option, isn't the css link supposed to go below the bootstrap's link in order for it to overwrite the bootstrap?
John Steer-Fowler
Courses Plus Student 11,734 PointsYes, you're right. Don't know what I was thinking there :D
Raymond Tran
6,285 PointsHaha! Anyway, thanks!
Raymond Tran
6,285 PointsRaymond Tran
6,285 PointsI've been using different kinds of CSS selectors to target and change the background color of this stacked navigation. It doesn't work. Please help!!