Is there a way to eliminate the gap between my menu choices?

Is there a way to eliminate the black line that appears between my menu options when using CSS hover?

https://jsfiddle.net/jameskelly/3ejsu7gx/2/

   a:hover {
     background-color: #ebebeb;
     font-color: black;
   }
   
   /* Custom styling for the navbar */
#navbar {
  overflow: hidden;
  background-color: #333;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 8px;
  }

/* Styling for the navbar links */
#navbar a {
  color: #f2f2f2;
  text-align: center;
  padding: 14px;
  content-align: center;    
}

#navbar current {
  color: black;
  text-align: center;
  padding: 14px;
  content-align: center;
  background-color: #ebebeb;
}

#navbar a:hover {
  color: black;
}
<div id="navbar">
  <current href="index.html">Home</current>
  <a href="about.html">About</a>
  <a href="services.html">Services</a>
</div>

Answer â„–1

When creating navigation menus, utilizing unordered lists is a simple way to maintain consistent styling. I updated the div element to a ul with the use of display:flex for the layout.

/* Custom styles for the navbar */

ul {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: #333;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 8px;
}


/* Navbar links */

li {
  text-align: center;
  list-style-type: none;
}

a {
  color: #f2f2f2;
  text-decoration: none;
  padding: 14px;
}

current a {
  color: black;
  text-align: center;
  padding: 14px;
  content-align: center;
  background-color: #ebebeb;
}

a:hover {
  background-color: #ebebeb;
  color: black;
}
<ul id="navbar">
  <li>
    <current><a href="index.html">Home</a></current>
  </li>
  <li><a href="about.html">About</a></li>
  <li><a href="services.html">Services</a></li>
</ul>

Answer â„–2

To enhance user experience, it is advisable to incorporate links in menu items with adequate spacing between them. Optimal presentation can be achieved by placing the menu items on a single line and utilizing unnumbered lists as the preferred menu format. Refer to this resource for additional guidance.

<div id="navbar">
  <current href="index.html">Home</current><a href="about.html">About</a><a href="services.html">Services</a>
</div>

Answer â„–3

If you want to make use of the display flex feature, all you need to do is apply these two properties to the navbar div:

#navbar {
  overflow: hidden;
  background-color: #333;
  text-align: center;
  padding-top: 8px;
  padding-bottom: 8px;
  
  display:flex;
  justify-content: center;
  }

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

Ways to dynamically apply styles to the component tag depending on the visibility of its content

Consider a scenario where you have a component with logic to toggle the visibility of its contents: @Component({ selector: 'hello', template: `<div *ngIf="visible"> <h1>Hello {{name}}!</h1></div>`, styles: [`h1 { fo ...

Looking for ways to ensure React is responsive and feeling a bit challenged by the React mentality?

I'm still getting the hang of ReactJS, and I've been facing some challenges with making React components responsive. For my app, I am utilizing react-tabs. It works well when the screen is wide, but I need to switch to a hamburger panel layout w ...

A guide to customizing the appearance of Textfield labels in Material-UI using React

Can someone assist me with changing the label color in Material-UI from grey to black? I am new to Material-UI and struggling to figure it out. Below is the code snippet: import React from "react"; import ReactDOM from "react-dom"; import { TextField, Bu ...

Problem with HTML produced by a loop

I am encountering difficulties when trying to create a collapsible list of elements. You can view my code on JSFiddle This is what my code looks like: <div class="projectscontainer"> <span class="item destproject" title="ID: 384">Kaoweuza ...

Conceal the element if the output of express is void

I am currently developing an app using nodejs and express. I am retrieving JSON data from an endpoint and displaying it on the page based on the values received. The issue I am facing is that if I receive a null or undefined value from the JSON data, how ...

Is there a way to arrange my bootstrap navigation tabs vertically on my mobile device?

I have a group of five bootstrap navigation tabs that are evenly spaced and visually appealing on desktop screens. However, when viewed on a mobile device, the text within the tabs becomes cramped together. How can I make the tabs stack vertically on mobil ...

Tips for saving input data from an HTML page to a text file

How can I save the inputs from a simple form as a text file using HTML code? Here is an example of the HTML code: <div id="wrapper"> <div class="main-content"> <div class="header"> </div> ...

Turn off automatic resizing of iframes

I'm currently dealing with a webpage that contains an iframe. The iframe contains quite a bit of data, and every time it loads, its height adjusts to match the content within. Unfortunately, this is causing my page layout to be disrupted. Is there a w ...

The jQuery.addClass() function seems to be malfunctioning

I'm encountering an issue with the addClass() method. For some reason, it's not functioning properly in this scenario: https://jsfiddle.net/0g1Lvk2j/20/ If you scroll to the end and close the last box by clicking on the orange box, the orange b ...

Including a CSS link in a .css file is an essential step in styling

Can someone guide me on how to reference the Bootstrap link (https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css) in a .css file within an Angular project? ...

How can I create two buttons on one line in a Struts2 form?

My form has two buttons - one for registering and the other for canceling the form. I created them using the following code: <s:submit name="cancel" key="project.button.cancel" /> <s:submit name="login" key="form.register.registerBtn" /> How ...

Verify the status of the internet button and display a message indicating whether it has been selected or not

I’ve been attempting to complete this task: opening this particular page in Python, and observing the outcome when the "Remote eligible" button is enabled; do any job positions appear or not? Here's the code I have so far, but it keeps throwing thi ...

After trying out the demonstration on the website, I am unable to get my submit button to work

Having trouble with my Formsubmit feature. Despite following the example on the website, my submit button doesn't send anything and the verification isn't reaching my email. Currently working with Angular. <form action="https://formsubmi ...

Tips for creating a dynamic curved SVG path

I'm looking to draw a black border only along the inside of this SVG. I've tried adding stroke and setting the stroke-width, but that applies the border to the entire SVG. Is there a way to limit the stroke to a certain point within the SVG? d ...

Developing an IF statement in JavaScript that relies on hexadecimal color values

I've created a JavaScript code that changes the background color of my webpage every time it loads: document.getElementById("band").style.background = '#'+(Math.random()*0xFFFFFF<<0).toString(16); To improve visibility, I am aiming t ...

What are the benefits of using Semantic mark-up and WAI-ARIA in a Tabbed Section?

Currently working on the structure of a website and aiming to improve accessibility skills. I'm curious about the most appropriate way to mark up tabbed content. Here's what I have so far: <section> <nav> <a href="#tab" aria ...

Selenium struggles to locate elements within Iframes even when they are clearly visible

My current project involves developing code to automatically log into the Life is Feudal game website in order to gather specific information. This information is legally accessible manually, but it would be extremely time-consuming to collect everything w ...

Accessibility issues detected in Bootstrap toggle buttons

I've been experimenting with implementing the Bootstrap toggle button, but I'm having an issue where I can't 'tab' to them using the keyboard due to something in their js script. Interestingly, when I remove the js script, I'm ...

Highlighting a specific list item dynamically without affecting its nested children

While I have come across similar questions, they don't quite address the specific issue I'm facing. My current project involves creating a keyboard-accessible tree widget. My goal is to apply a background color to the selected list item without ...

The duplication and multiplication of margin-left is occurring

I am baffled by the fact that margin-left is only affecting certain elements and causing frustration. .setting-container { position: relative; top: 60px; left: 0px; width: 100%; height: calc(100% - 60px); } .setting-topnav { width: 100%; h ...