What is the best way to get rid of unnecessary white spaces above the header and below the footer when using Bootstrap

After creating a header and footer using Bootstrap and styling them with CSS, I've noticed some white space above the header and below the footer. Unfortunately, I'm unsure of what is causing this unwanted space to appear.

Below is the code snippet for reference:

header.php

<html dir="ltr" lang="en">
<head>

<title></title>

    <link rel="stylesheet" href="css/main.css" media="all">

    <link href="css/main.css" rel="stylesheet">
    <meta charset='utf-8' />
    <link href='fullcalendar.min.css' rel='stylesheet' />
    <link href='fullcalendar.print.min.css' rel='stylesheet' media='print' />
    <script src='lib/moment.min.js'></script>
    <script src='lib/jquery.min.js'></script>
    <script src='fullcalendar.min.js'></script>
</head>

 <nav class="navbar navbar-expand-lg navbar-static-top" id="topNav">
    <img src="images/logo.png" alt="Logo">

</nav>

footer.php

<footer class="footer">
<div class="container">
    <p class="m-20 text-center text-white"><br></p>
</div>

</footer>

main.css

body {
margin-top: 60px;
margin-bottom: 100px;
}

.footer {
position: sticky;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px; 
background-color: #CC0033;
}

#topNav {
position: sticky;
width: 100%;
height: 70px;
line-height: 60px; 
background-color: #CC0033;
}

Answer №1

Not sure exactly what your goal is, but here's the issue I found: it seems to be related to the CSS. Make sure to review how the classes in the navigation section are functioning.

html,body {
height:100%;
}
body{
position:relative
}

.footer {
position: fixed;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px; 
background-color: #CC0033;
  left:0;
}

#topNav {
position: fixed;
  top:0;
  left:0;
width: 100%;
height: 70px;
line-height: 60px; 
background-color: #CC0033;
}
<html dir="ltr" lang="en">
<head>

<title></title>

    <link rel="stylesheet" href="css/main.css" media="all">

    <link href="css/main.css" rel="stylesheet">
    <meta charset='utf-8' />
    <link href='fullcalendar.min.css' rel='stylesheet' />
    <link href='fullcalendar.print.min.css' rel='stylesheet' media='print' />
    <script src='lib/moment.min.js'></script>
    <script src='lib/jquery.min.js'></script>
    <script src='fullcalendar.min.js'></script>
</head>

 <nav class="navbar navbar-expand-lg navbar-static-top" id="topNav">
    <img src="images/logo.png" alt="Logo">

</nav>


<footer class="footer">
<div class="container">
    <p class="m-20 text-center text-white"><br></p>
</div>

</footer>

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

Whenever I attempt to use window.print(), the styling gets completely messed up. I've experimented with both @media screen and @media print, but unfortunately, I

I am working on creating an invoice, the design looks perfect in the browser, but when I try to window.print() the style gets corrupted. I attempted to include @media screen and @media print, but I am still facing the same issue. The invoice form is incorp ...

Does CSS make server calls if it's contained in a div with display:none set?

How will a browser handle loading two blocks of code that are managed to be shown or hidden using CSS display:none on separate style sheets? If the page is loaded in the browser and this detection is made, will the code inside the div still load but just ...

Using Jquery to create a fading effect when changing the color by checking a checkbox

I'm struggling with adding a fading effect to change the background color of the body element when a checkbox is checked. The color changes successfully, but I can't figure out how to make it fade smoothly. Here is the HTML code: <div class=& ...

Flexbox Alignment Problem with Mixed Text and Image Elements

Struggling to achieve a layout like the one in this image using Flexbox. Take a look: https://i.sstatic.net/EGsAN.png After some difficulty with floats, I've decided to experiment with flexbox. My CSS is set up to display the image correctly. The ...

Switching up the navbar's background hue

Struggling to change the background color of individual navbar options using id's. Only the text in the navbar changes, not the background color. My goal is to have a unique background color for each navbar option within this bootstrap template I am c ...

The functionality for switching Bootstrap tabs on button click appears to be malfunctioning

I am facing an issue where I need to switch between bootstrap tabs on a button click event only if a certain condition is satisfied. However, no matter what I try, the functionality doesn't work as expected. When I remove the updatepanel from the firs ...

Issues with the menu pop-up functionality arise when utilizing the CSS class .active

When I have this code, the ".active" function doesn't work when clicked. However, if I change the div class from "top-menu-popup" to "top-menu-popup active" when opening the page, the menu is already activated. <div class="top-menu-popup"> ...

What causes the navbar-brand to be hidden on Chrome mobile browsers?

I recently completed building my website at emdashr.com and have been adjusting the mobile views. However, I'm facing an issue where the navbar-brand disappears when viewing the site on mobile Chrome or desktop Chrome with a small viewport. Interestin ...

Trouble with clicking inner elements after applying JQuery code to parent div

Currently, I have implemented a code for toggling a search bar and it is functioning properly. The toggle function is applied to the main div using a click function in jQuery. While the toggling works fine, there seems to be an issue when clicking on the i ...

Mixing rel="preload" and rel="stylesheet" in a single tag: A guide

Google Pagespeed test is not able to recognize preload when it is used alongside a stylesheet. I attempted <link rel="preload stylesheet" href="http://www.example.com/style.css" /> and it continues to display the message "Consider using rel=preload ...

- Bullet point: Table heading alignment variation

When it comes to centering a <th> element inside an <li>, different browsers have different approaches. In Internet Explorer, Edge, and Safari, the <th> is center-justified. However, in Chrome, Firefox, and Opera, it's left-justifie ...

Execute javascript function upon user scrolling to a designated section in the webpage

Is there a method to trigger a unique function every time a user scrolls to a different div or section of the page? ...

The battle between Hover, Focus, and Blur modes intensifies

My goal is to implement 4 different effects on an element: When hovering over the element. When moving away from the element. When focusing on the element. When blurred. However, I'm encountering a conflict where when I focus on the element, the ...

What is the best way to utilize Selenium for choosing an item from a drop-down menu?

My current challenge involves using Selenium to interact with a dropdown menu in Python. The HTML snippet below shows the structure of the website I'm working on. <select data-id="1388874259461-k9k0y" name="walletselectedbitcoin" id="selectWallet" ...

Placing a Label Next to an Input Field using Bootstrap 4

Is there a way to position the label right next to the input form? I've attempted different methods without success. Could you please review my code below? <div class="modal-body"> <form class="form-horizontal"> <div cl ...

Hide the footer DIV in CSS by making it disappear with a height of 100%

I'm currently facing an issue with my CSS layout. Despite managing the problem in IE and seeing everything work well, the footer container has mysteriously disappeared! I've attempted to recode the CSS without success, even after trying for days ...

What is the best way to retrieve the current CSS width of a Vue component within a flexbox layout grid after it has been modified?

There's something about this Vue lifecycle that has me scratching my head. Let me simplify it as best I can. I've got a custom button component whose size is controlled by a flex grid container setup like this: <template> < ...

Exploring the Contrasts Between HTML String and Emphasizing the Variances

Challenge Description: The task is to compare two HTML input strings with various styling elements like strong, li, ol, line-through, etc. The goal is to display the original text and the edited text in two separate boxes on the screen. Any words missing i ...

What is the best way to animate CSS elements using jQuery to slide in from the right, left, or bottom?

When the page is scrolled on my website, I want table_area-left to move from left to right to its current position, table_area-right to move from right to left to its current position, and morph button to move from down to up. I am struggling to find the j ...

Basic alignment in a table and on a webpage using HTML

I have a basic HTML table that needs some alignment adjustments. <table align="center" border="1" cellpadding="0" cellspacing="0" style="width:1000px"> <thead> <tr> <th scope="row">BB<br /> ...