The margin for the navbar cannot be set to "0"

I'm currently in the process of building a website, and I decided to experiment with integrating Bootstrap into it. I've utilized the navbar tags along with some custom CSS, but I'm facing an issue with removing the margin. As a result, the appearance of the navbar is not quite right.

Here's the code snippet:

HTML:


<!DOCTYPE html>
<html lang="en">
    <head>
        <title>
            Hilo | Home</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="/styles.css">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="42202d2d36313630233202766c776c71">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
        <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="https://cdn.linearicons.com/free/1.0.0/icon-font.min.css">
    </head>
    <body class="body-fr">
        <nav class="navbar" role="navigation">
            <div class="container-fluid nav-container-fr">
                <ul class="nav-nav">
                    <li class="nav-item-fr"><a href="#" class="nav-link nav-size">Home</a></li>
                    <li class="nav-item-fr"><a href="#" class="nav-link nav-size">Streams</a></li>
                    <li class="nav-item-fr"><a href="#" class="nav-link nav-size">Followed</a></li>
                    <li class="nav-item-fr nav-icon-fr"><a href="#" class="nav-link"><i class="lnr lnr-user fs-40"></i></a></li>
                    <li class="nav-item-fr nav-cog-fr"><a href="#" class="nav-link"><i class="lnr lnr-cog fs-40"></i></a></li>
                </ul>
            </div>
        </nav>
    </body> 
</html>

CSS:


* {
    margin: 0;
    padding: 0;
}

.body-fr {
    background-color: #333;
}

nav {
    margin: 0;
    padding: 0;
    width: 100%;
}

.navbar {
    margin: 0px;
    padding: 0px;
}

.nav-container-fr {
    width: 100%;
    display: flex;
    justify-content: space-around;
    text-align: center;
    background-color: #222;
}

.nav-nav {
    justify-content: space-around;
    list-style-type: none;
    list-style: none;
    display: inline;
    margin: auto;
    margin-bottom: 5px;
}

.nav-size {
    font-size: 30px;
}

.nav-item-fr {
    text-align: center;
    display: inline-flex;
    margin: 0 30px;
}

.nav-icon-fr {
    margin-top: 5px;
    margin-left: 470px;
    margin-right: -40px;
}

.nav-cog-fr {
    margin-right: -50px;
}

.fs-20 {
    font-size: 20px;
}

.fs-40 {
    font-size: 40px;
}

.fs-60 {
    font-size: 60px;
}

.fs-80 {
    font-size: 80px;
}

.fs-100 {
    font-size: 100px;
}

.fs-120 {
    font-size: 120px;
}

If anyone could provide some guidance on how to resolve this issue, I would greatly appreciate it. Please excuse the messy code, as I am still fairly new to bootstrap and haven't had the chance to tidy up the CSS yet.

Answer №1

To resolve the issue, you may want to consider implementing the following CSS code:

margin: 0 !important;

If that doesn't work, try using a more specific selector.

For example, when you inspect the element in Chrome, you might find a more targeted selector.

For instance:

html body nav {
    margin: 20px;
}

Would take precedence over:

nav {
    margin: 0;
}

In this scenario, a margin of 20px would be applied successfully.

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

What is the best way to toggle the visibility of my menu using JavaScript?

I recently implemented a script to modify a CSS property in my nav bar as I scroll down, triggering the change after reaching 100px. $(window).scroll(function() { var scroll = $(window).scrollTop(); //console.log(scroll); if ...

The combination of jQuery, using .load method in javascript to prevent scrolling up, making XMLHttpRequest requests, updating .innerHTML elements, and troubleshooting CSS/JS

While utilizing this code, CSS and Javascript are disabled (only HTML loads): function loadContent(limit) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status ...

Struggling to display a function's output on a separate web page within a flask application

After spending close to 10 hours on this, I find myself stuck. My restaurant search app is functioning perfectly when I print the output to the terminal. However, I can't seem to figure out how to display it on a new page. Here's a snippet of my ...

The central navigation system of the Owl Carousel

I am currently using the owl carousel plugin and I am struggling to figure out how to center align the navigation vertically while also using the autoHeight option. http://codepen.io/anon/pen/jJAHL I have attempted the following code snippet, but it seem ...

A full-width CSS menu featuring dropdowns beneath each entry for easy navigation

Check out the JSFiddle here I've created a full-width CSS menu that spans the entire screen, but I'm struggling to figure out how to make the corresponding subnav items appear below their parent items. Is it even possible to achieve this design ...

The scroll bar is visible on the scroll box, but unfortunately it is not functional in Internet Explorer 8

http://example.com/code <div style="width:625px;height:220px;overflow-y:hidden;overflow-x:scroll;z-index:10;"> <table width="1000" height="114" border="1"> <tr> <td width ...

Creating elegant Select Dropdown Box in AngularJS without relying on images

I am currently working on an angular page and have implemented a dropdown with ng-Options to fetch and set values successfully. However, I am now looking to enhance the appearance of this dropdown. After exploring options like ui-select, I realized that be ...

What are the different methods for completing a form?

From what I understand, there are 2 methods for submitting a form. For instance, in asp.net, there is the Button.UseSubmitBehavior property which Specifies whether the Button control uses the client browser's submit mechanism or the ASP.NET postb ...

Aligning the tooltip element vertically

I've created a unique flexbox calendar layout with CSS tooltips that appear on hover. One challenge I'm facing is vertically aligning these tooltips with the corresponding calendar dates effectively. Although I prefer to achieve this alignment u ...

Various SVG paths make up segments

I have created an intricate SVG file containing 35 different paths resembling train tracks. My next step is to break down these paths into 16 segments, allowing another SVG path (train) to smoothly traverse along them. The ultimate goal is to grant users ...

Correctly align the div on the screen as the viewport is scrolled

I am currently working on a parallax website where the sliders are designed to slide from the left and align within the viewport as the user scrolls. However, I have encountered an issue where multiple scroll actions are required for the slide to align pro ...

Embed the image within the form input

I am trying to incorporate an SVG image into a bootstrap form input, similar to this example: https://i.sstatic.net/7ZSRH.png This is the HTML code: <div class="col-md-6"> <div class="subscribe-wrapper subscribe2-wrapper mb-15&q ...

Bootstrap 4 does not have the capability to include spacing between two columns

I'm encountering an issue with adding a gutter between 2 columns on my website layout. I have a row that needs to be 1280px wide (based on a reference resolution of 1366x768 with padding of 43px on each side of the page), containing two sections that ...

What is the process for transferring a folder to public storage in Laravel?

I've been attempting to upload and save a folder (which contains several files) into my local directory, but I'm encountering difficulties. Below is the input form I have: <input type="file" name="folder" id="folder&q ...

What is the best way to obtain the value of a radio button using ajax?

Here is the search button in my PHP file. I am unsure of how to connect the radio button to the JavaScript file. <button id="submit">Search</button> This is the starting point in the JavaScript file var xhr = new XMLHttpRequest(); f ...

How can I enable the "Open in a new tab" functionality while utilizing ng-click?

I've encountered an issue with my HTML table where each row is supposed to link to a different page, providing more detailed information. However, because I am using angularjs and utilizing ng-click on the rows, I am unable to right-click and select & ...

Converting a lengthy HTML document into numerous JPEGs (or any preferred image format)

I am working on a lengthy webpage that can be viewed as having 40 individual pages. Each "page" is separated by a horizontal rule () and has a fixed height of 860px. My goal is to convert each of these "pages" into JPG images automatically. Can anyone pr ...

Tap to smoothly scroll through each block using the animate() function

ul { padding: 0; margin: 0; height: 180px; overflow: auto; } li { height: 50px; background: pink; list-style: none; margin-bottom: 10px; height: 50px; ...

Retrieving innerHTML from a VueJS custom component

Attempting to create a basic bootstrap alert component, I am struggling to access the innerHTML of my custom component. Here is the code snippet: Vue.component('my-alert', { template: '#vue-alert', props: ['type', ' ...

Storing an ID field across different domains using HTML and JavaScript: Best Practices

Currently, my web app includes a conversion tracking feature that analyzes whether activity "A" by a website visitor leads to action "B." This feature works effectively when the tracking is contained within a single domain but encounters issues across mul ...