forming a boundary that stands alone, unattached to any other boundaries

I am trying to design a navigation bar that resembles the one depicted in the image provided.

The concept involves creating a navigation bar where each border is separated from the others, potentially achieved using hr tags. However, I am struggling to figure out how to make it vertical and fit seamlessly within the Nav bar.

.topnav {
  background-color: lightgray;
  overflow: hidden;
  border-top: 1px solid grey;
  border-left: none;
  border-bottom: none;
}


/* Style the links inside the navigation bar */

.topnav a {
  color: #575859;
  text-align: center;
  display: inline-block;
  width: 16.15%;
  height: 80px;
  text-decoration: none;
  font-size: 17px;
  border-right: 1px solid grey;
}


/* Change the color of links on hover */

.topnav a:hover {
  background-color: #F0191C;
  color: white;
}


/* Add a color to the active/current link */

.topnav a.active {
  background-color: #4CAF50;
  color: white;
}
<div class="topnav" id="myTopnav">
  <a href="C:\Users\Cdogb\Documents\coursework\year 1\web design\coursework 2\website\index.html">Home</a>
  <a href="C:\Users\Cdogb\Documents\coursework\year 1\web design\coursework 2\website\product.html">Products</a>
  <a href="#index">Protect</a>
  <a href="#index">Stocklist's</a>
  <a href="#index">Events</a>
  <a href="#reviews">Reviews</a>
</div>

Answer №1

To style your CSS, set a specific height for the topnav element that is larger than its child elements, particularly the a child. Additionally, add padding to vertically center the a child within the topnav. To further center the text within the a child, include a line-height. While this solution may be basic, it should guide you in the right direction.

.topnav {
    background-color: lightgray;
    overflow: hidden;
    border-top: 1px solid grey;
    border-left: none;
    border-bottom: none;
    height:45px;                                      /* Adjusted height */
    padding: 10px 0 10px 0;                           /* Added padding */
}

/* Style the links inside the navigation bar */
.topnav a {
    
    color: #575859;
    text-align: center;
    display:inline-block;
    width: 16.15%;
    height: 40px;                                     /* Modified height */
    text-decoration: none;
    font-size: 17px;
    border-right: 1px solid grey;
    line-height:40px;                                 /* Added line-height */
}


/* Change the color of links on hover */
.topnav a:hover {
    background-color: #F0191C;
    color: white;
}

/* Add a color to the active/current link */
.topnav a.active {
  background-color: #4CAF50;
  color: white;
}
<div class="topnav" id="myTopnav">
     <a href = "C:\Users\Cdogb\Documents\coursework\year 1\web design\coursework 2\website\index.html">Home</a>
     <a href = "C:\Users\Cdogb\Documents\coursework\year 1\web design\coursework 2\website\product.html">Products</a>
     <a href = "#index">Protect</a>
     <a href = "#index">Stocklist's</a>
    </div>

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

Angular 6: A guide to dynamically highlighting navbar elements based on scroll position

I am currently building a single page using Angular 6. The page is quite basic, and my goal is to emphasize the navbar based on scrolling. Below is the code snippet I am working with: .sticky { position: sticky; top: 0; } #i ul { list-style-type: ...

Changing the size of a dynamic watermark png in php

I'm trying to automate the resizing of a watermark to cover 1/4 of an image. The code for the watermark is functioning, but I'm facing issues with resizing it correctly. <?php $image = $_GET['src']; $path_parts = pathinfo($image); ...

Eliminate gaps between lines in a wrapped Flexbox layout

I am trying to eliminate the spaces between rows in a horizontal list flexbox. I am creating an alphabetical list and I want it to flow seamlessly without any gaps. This is what I have so far: #example { display: block; margin-left: auto; margin-r ...

Creating a dynamic animation effect on a div with a changing number of child elements

Currently, I am utilizing the nganimate library and have implemented an animation that affects the max-height property of a div. Here is a snippet of my code: CSS .sublist.ng-hide { max-height: 0; } .sublist { max-height: 1300px; overflow: hidden; ...

Using CSS and Vue, you can customize the appearance of inactive thumbnails by displaying them

My goal is for a clicked thumbnail to display in color while the others show as grey. The active thumbnail will be in color, and I want inactive thumbnails to appear in grey. Here is what I am trying to achieve: Vue.component('carousel', { ...

Retrieve the input name array key value using jQuery from the adjacent TD

It's a tough one to summarize in the title, but here is the code snippet that explains it: <tr class=""> <td> <input value="9" name="set[122][order]"></input> <input class="set-id ...

Using Node.JS, Sequelize, and Moment.JS to format dates

Seeking help on formatting a date loaded from Sequelize in my database. I'm working on a blog and need to display the creation date of an article. Here's my route: app.get("/", (req,res) =>{ Article.findAll({ order:[ [ ...

Using Javascript to dynamically add form fields based on the selection made in a combo box

I am in the process of creating an information submission page for a website, where various fields will need to be dynamically generated based on the selection made in a combo box. For example, if the user selects "2" from the combo box, then two addition ...

Exploring the Relationship Between Z-Index and Overflow in a Collapsible Div Featuring Slim Select

Here is my demonstration of embedding a Slim Select dropdown within a collapsible div: CodePen Example <html> <head> <!-- MULTIPLE SELECT DROPDOWNS --> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ ...

HTML and CSS are two separate languages that work together to create web pages

I'm experiencing an issue with my CSS file not responding to my HTML file. I have imported the CSS file into my HTML file and both files are located in the same directory. It was working fine when they were written in the same file, but after separati ...

PubNub's integration of WebRTC technology allows for seamless video streaming capabilities

I've been exploring the WebRTC sdk by PubNub and so far, everything has been smooth sailing. However, I'm facing a challenge when it comes to displaying video from a client on my screen. Following their documentation and tutorials, I have writte ...

Issue with Wordpress Submenu Items not Displaying

I've included sub menu items in my primary navigation, but they're not visible at all? I've examined the css and haven't found any code that would hide the sub menu. ul.art-hmenu { display: inline-block; vertical-align: midd ...

Sending array values from a dynamic input field in Angular 4 and processing them accordingly

I am currently exploring options on how to add and delete multiple input fields. When a user submits two or more fields, I want the results to be displayed in an array. This is my HTML form: <form method="post" [formGroup]="formData"> ...

What are the differences between ajax loaded content and traditional content loading?

Can you explain the distinction between the DOM loaded by AJAX and the existing DOM of a webpage? Is it possible to load all parts of an HTML page via AJAX without any discrepancies compared to the existing content, including meta tags, scripts, styles, e ...

Rearrange the order of items in the fancybox gallery

Typically, fancybox displays items in the gallery based on the order they are added in the HTML code. Is there a way to customize the order of items when they are opened in the popup, while keeping the original order when displayed on the page? The solut ...

Trigger Polymer() callback when the element is displayed

Is there a way to implement a callback in the Polymer({}) object that triggers every time the element is displayed? ready doesn't fit the criteria as it's called during the initial page load when the element is created. I'm looking for an ...

Tips for resolving a flickering issue that occurs when switching to an input field with our default value / placeholder plugin

In the realm of web development, numerous plugins cater to the implementation of HTML5's placeholder attribute in older browsers. The plugin we have opted for can be found here. Unlike some other alternatives, this particular plugin, with a few modif ...

Display the query results on a separate blade

In my original attempt, I intended to display the results in a modal but later decided to show them in a different blade. My goal is to fetch all comments related to a post using its post_id. However, I encountered the following error: The GET method is no ...

The Ion-button seems to be malfunctioning

I am interested in using special buttons for my ionic 1 project, specifically the ion-button feature outlined on this page: Ionic Buttons. I attempted to create a Round Button and an Outline + Round Button: <h2 class="sub-header" style="color:#4 ...

Ways to extract specific HTML from a jQuery element

When fetching html from a website, how can I extract specific html content instead of getting all of it? I have attempted the following method: Before appending data to the target below container.html(data); I would like to perform something like data.f ...