CSS margin to the left of every navigation bar button

On smaller screens, I updated my navbar buttons to be vertical using a media query. However, I encountered an issue where there is blank space to the left of each button despite not having a left margin in my code. Any help on how to resolve this would be greatly appreciated.

CSS:

/* Navbar */
#navbar {
    background-color: #599;
    list-style-type: none;
    overflow: hidden;
    margin: 0px;
    width: auto;
    text-align: centre;
    font-family: 'corbel','arial';
    text-align: center; 
}

#nav_li {
    float: left;
    display: inline;
    text-align: center;
}

#nav_a {
    text-decoration: none;  
    margin: 10px;
    display: inline-block;
    color: white;
}



/* Media queries for smaller screens*/
@media screen and (max-width : 350px){

    /* reduce padding */
    header nav a{padding:.7em .7em; }
    [role=main]{padding:1.5em 1.5em;}

    /* make navbar vertical */
    #nav_li{text-align: center;
            border-bottom: 1px solid #eee;}
    #nav_li, #navbar_a{width: 100%;}

HTML:

<ul id='navbar'>
    <li id='nav_li'><a id='nav_a' href='index.html'>Home</a></li>
    <li id='nav_li'><a id='nav_a' href='gallery.html'>Gallery</a></li>
    <li id='nav_li'><a id='nav_a' href='testimonials.html'>Testimonials</a></li>
    <li id='nav_li'><a id='nav_a' href='contact.html'>Contact </a></li> 
</ul>

Answer №1

To fix the default padding on the left side of a UL element, you can apply the following CSS:

#navbar {
    padding-left: 0;
}

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

Adjust the position of a textarea on an image using a slider

Currently, I am exploring how to creatively position a textarea on an image. The idea is to overlay the text on the image within the textarea and then use a slider to adjust the vertical position of the text as a percentage of the image height. For instanc ...

Utilizing unique background images tailored to different screen resolutions

In order to enhance the user experience on my website, I am looking to implement a feature that dynamically changes the background images based on the user's screen resolution. My plan is to use a small snippet of JavaScript within the <head> s ...

Is it necessary to use a specific button to submit on Return (Enter)?

In a wizard-type form, there are two buttons present. The Back button is positioned on the left side, while the Next button is located on the right side. For an example of this setup, visit http://jsfiddle.net/WSwb7/1/. Please note that submitting the form ...

Showing off the latest products at the top of the list

Typically, when utilizing ngFor, the most recent item is displayed underneath the initial element. For instance, a list containing: [Apple, Orange, Banana] If we use ngFor to display this list: Apple Orange Banana I am interested in learning a method t ...

The CSS top border is failing to display

For a school project, I've been attempting to add a top border to a set of hyperlinks in order to separate them from the title. However, after spending over an hour on this task, I still can't seem to get it to work. Below is the CSS code for th ...

html interactive/expandable tree

I've come across this code which generates an HTML tree, but I'm facing an issue where the tree expands every time I refresh the page. What I want to achieve is to have certain branches expanded and others collapsed when the page is opened, depe ...

Influencing various classes when :active is triggered

I encountered a challenge while working on an HTML project. I included a checkbox that should highlight all text input fields when checked. However, I'm facing an issue where some of the input fields within tables are not being affected by my code. An ...

DIV size issue resolved

Content within a div is surpassing the set fixed size determined by CSS. <style> #fixeddiv { position: fixed; margin: auto; max-height: 300px; max-width: 700px; } </style> <div id="fixeddiv"> <div id="M77 ...

How can I position two divs side by side within an Appbar?

I would like the entire Container to be in a single row, with the Typography centered as it already is, and the toggle-container to float to the right <AppBar className={styles.AppBar}> <Toolbar> <Container> ...

I'm encountering an undefined JavaScript variable, how should I proceed?

$(function(){ //Location was "set". Perform actions. $("#geocodesubmit").click(function(){ var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status ...

What steps can be taken to make sure padding impacts all lines, not just the first one?

I have added padding to a span of text using Bootstrap. However, the issue arises when the text goes to the next line using < br > - the padding for that line and beyond disappears. Here is the specific code causing this problem: <div class="col ...

Manipulate React class names by adding or removing them

Is there a way to toggle a className on click to change the style of a component? https://i.sstatic.net/z9FoA.png I need to rotate an arrow to the right when it's clicked and hide all components next to it using display: none;. I also require t ...

Bootstrap's anchored footer fix

Exploring Bootstrap and I'm curious about how to keep the footer fixed at the bottom of the page without it disappearing when scrolling through the content. Any suggestions? ...

Embellishing Bootstrap with a splash of color class

After exploring Bootstrap, I've noticed the limited number of "color classes" available (primary, success, danger etc.). Is there a simple way to add more classes similar to those? For instance, the "primary" class can be used across various elements ...

Position Bootstrap Modal in the center horizontally

I am working on an Angular project and struggling to center my Bootstrap 3 Modal horizontally on the screen. Despite trying various solutions like using text-align: center and align = "center", I have been unsuccessful. Can someone guide me on how to prope ...

The table is overflowing its parent element by exceeding 100% width. How can this issue be resolved using only CSS?

My root div has a width of 100% and I need to ensure that all children do not overlap (overflow:hidden) or exceed the 100% width. While this works well with inner <div>s, using <table>s often causes the table to extend beyond the parent 100% d ...

Are HTML attribute names really case-sensitive? A topic filled with conflicting information

After learning that attribute names are case-sensitive, I found conflicting information. A source mentioned that attribute names are indeed case-sensitive. For example, the width attributes in <div> and <DIV> would be considered separate due ...

Crafting a template for mixing up images and quotes without any specific connection - here's how!

I came across some interesting templates that can generate random quotes and others that create random pictures. My goal is to develop a template that generates both a random quote and a random picture, similar to this example, without any relation betwee ...

Ensuring a consistently positioned footer at the bottom

I understand that this might not seem like a significant issue, but I'm encountering some difficulties. In my main.html file, there are three divs. The first div contains the navigation bar, the second div is an "empty" div that uses JQuery/Javascript ...

Curious about how to swap the positions of these two divs?

After wrapping them in divs and adding inline-block to both elements to display them side by side, I'm now exploring options to switch their positions. Specifically, I'd like the right element to be on the left. Any ideas on how to achieve this? ...