/*style.css*/
/* Styling the sidebar */
.sidebar {
width: 200px;
float: left;
border-right: 1px solid #ddd;
}
.nav {
list-style-type: none;
padding: 0;
}
.nav-link {
display: block;
padding: 10px;
text-decoration: none;
color: #000;
}
.nav-link:hover {
background-color: #f0f0f0;
}
/* Custom style for active link */
.nav-link.active {
background-color: #007bff; /* blue highlight background */
color: #ffffff; /* Text color when active */
font-weight: bold; /* Optional: Make the text bold*/
}
/*Main content area*/
.content {
margin-left: 220px;
padding: 20px;
}
<div class="bookdown">
<div class="sidebar">
<ul class="nav">
<li><a href="#section1" class="nav-link">Section 1</a></li>
<li><a href="#section2" class="nav-link">Section 2</a></li>
<li><a href="#section3" class="nav-link active">Section 3</a></li>
<li><a href="#section4" class="nav-link">Section 4</a></li>
</ul>
</div>
<div class="content">
<h1 id="section1">Section 1</h1>
<p>Content for section 1.</p>
<h1 id="section2">Section 2</h1>
<p>Content for section 2.</p>
<h1 id="section3">Section 3</h1>
<p>Content for section 3.</p>
<h1 id="section4">Section 4</h1>
<p>Content for section 4.</p>
</div>
</div>
The sidebar consists of a list of links <ul class="nav">
where one is marked with the active
class.
The sections of the page are contained within the content
div.
.nav-link
styles the appearance of sidebar links.
.nav-link.active
customizes the active link, changing its colors to blue #007bff
and white #ffffff
. You can modify these shades as needed.