Ways to emphasize specific sections of the navigation bar

I am currently in the process of coding my own portfolio as part of my UX/UI program. My navigation bar is styled using the CSS code below:

.nav-links {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  grid-column-start: span;
  list-style-type: none;
  font-family: eurostile, sans-serif;
  font-size: 24px;
  justify-items: center;
  background-color: #7510f7;
  margin-right: -10px;
  margin-left: -10px;
  margin-top: -10px;
  padding: 15px;
}

.nav-item a {
  text-decoration: none;
  color: white;
  font-weight: lighter;
}

Each navigation link corresponds to one column of the grid.

I am trying to find a way to change the background color of a specific column in the grid to indicate which page the user is currently on. Is this achievable through CSS? Alternatively, are there other methods I can use to show the user's current location?

Edit: Here is the HTML structure for the Navigation Bar:

<header>
    <nav>
        <ul class="nav-links">
            <li class="nav-item"><a href="home.html">Home</a></li>
            <li class="nav-item"><a href="contextual_inquiry.html">Contextual Inquiry</a></li>
            <li class="nav-item"><a href="interaction_Design.html">Interaction Design</a> </li>
            <li class="nav-item"><a href="skills.html">Skills</a> </li>
            <li class="nav-item"><a href="about.html">About</a> </li>
        </ul>
    </nav>
</header>

Edit: A live version of the website has been deployed for better visualization:

Answer №1

If you know which page is active, you can dynamically add the class active to the list item and then style it as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why does the last-of-type selector work, but the first-of-type doesn't seem to?

The SCSS code snippet below is causing me some confusion: li { &.menu-item-type-custom { margin-bottom: 10px; a { // } &:last-of-type { margin-bottom: 40px; } &:first-of-type { margin-top: 40px; ...

How to apply background images to LI elements using CSS

I've been experimenting with CSS-generated tabs to display an active state of an arrow underneath the tab. I tried using the background position properties to position the image for the hover event, but it would extend beyond the predefined boundaries ...

What is the best method for implementing page transitions between components in NextJS?

My goal is to create a form that smoothly slides to the right, similar to the one seen on DigitalOcean's website when you click "Sign up using email" here: . While the transition itself is relatively simple, I noticed that DigitalOcean uses 2 separat ...

How to dynamically change the color of an AngularJS element based on a condition?

As someone who is new to AngularJS, I am currently working on changing the color of a table element to yellow if the user has voted on a specific choice. <div ng-show="poll.userVoted"> <table class="result-table"> <t ...

Utilizing CSS for styling a class with a dynamic name

On the server side, I am dynamically generating class names like this: <p class="level_1">List item 1</p> <p class="level_2">List item 2</p> <p class="level_3">List item 3</p> <p class="level_1">List item 1</p& ...

The style in App.js was rejected and the script was not executed as intended

element, I have encountered a common issue that many others seem to face. The typical solution involves correcting a line of code like this one: app.use(express.static(__dirname + '/public')); Unfortunately, despite my efforts to follow the ad ...

Monochrome tabletop solid in one hue

I'm trying to eliminate the space between the columns in my table so it looks solid. Here's the CSS style I've been using: <style> tr, th, td {margin:0;padding:0;border:0;outline:0;font-size:90%;background:transparent;} table{ margin: ...

Customizing Bootstrap navbar classes - ineffective

Having trouble overriding some of Bootstrap's navbar classes. I've tried using !important, but would prefer to avoid it if possible. This is the HTML I'm working with: <nav class="navbar navbar-default" role="navigation"> <ul cl ...

Tips for maintaining the integrity of blank space within a text node?

When intercepting a paste event and cleaning HTML off of the content using textNodes, I am faced with an issue where all white space is reduced to a single space and new lines are disregarded. For example, pasting: "hello world !" ends up being "h ...

Tips for ensuring consistent position and size across various window dimensions with CSS

Can someone please assist me in centering an image in the window and ensuring it stays the same size regardless of the window size? I'm unsure how to accomplish this, any tips or guidance would be greatly appreciated. ...

Getting rid of any excess space between columns within the same row in Bootstrap following a line

Exploring Bootstrap 3. When you test the following HTML and CSS code, everything appears as expected with no space above 768px. However, upon reaching that breakpoint, the divs start stacking on top of each other, which is fine. But suddenly, a mysterious ...

Vertical text area expansion functioning in Chrome, but not in Firefox

Is there a way to create a textarea that dynamically expands to fill the available space within a div, while maintaining fixed height offsets from the top and bottom? The CSS code below achieves this effect in Chrome, but Firefox displays the textarea with ...

Is it possible to simultaneously run watchify and node-sass watch together?

Currently, I am utilizing npm scripts in conjunction with watchify and node-sass while incorporating the -w parameter. I am curious if it is feasible to execute both of these 'watch' commands simultaneously. Would this setup ensure that only sty ...

What causes a webpage to overflow when using the position:absolute property?

Despite my understanding that an element positioned absolutely should be removed from the normal content flow, why does it still cause the page to overflow? Running the code snippet below reveals a horizontal scrollbar, which I didn't expect. .rela ...

Issue with spacing between rows of inline-block elements and adjacent rows

Just to clarify, this is not a table. I used "row" as a placeholder term. My issue involves a set of inline-block elements with a gap below them when compared to another element on the page. This is different from the space between the inline elements the ...

What is the best way to incorporate a variety of colors into a single element?

Using a combination of colors in one element I'm looking for ways to incorporate multiple colors into a single element effectively. My initial attempt with the color mix function didn't work as expected, so I need new ideas and techniques on how ...

Issue with CKEditor within a ColorBox dialog box

Could someone please assist me? I am facing an issue with my HTML page where I have incorporated a ColorBox modal popup. Inside the ColorBox popup, there is a CKEditor. The problem is as described below: In Internet Explorer, the CKEditor functions proper ...

CSS grid tracks remain fixed in size while other tracks expand

Why won't the grid track cells dynamically shrink when other cells are enlarged in the following code? In this snippet, hovering over any track section causes that cell to grow to 75% of the viewpoint. However, instead of the other sections shrinking ...

Guide on shifting components (main page, attributes, cost, drop-down menu) to the right section of the navigation bar?

<div class="container"> <nav class="navbar navbar-toggleable-lg fixed-top navbar-light bg-faded"> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navb ...

Displaying elements in Angular based on their height

I'm currently working on a paragraph that adjusts its length based on the maximum height. I'm interested in finding a way to display or hide the anchor element if the height exceeds a specific limit. Essentially, I only want to show "more..." whe ...