When the Navbar div is set to Position:fixed, it generates empty space on the page

I'm facing the issue of unwanted white space in the center of the page below the Navigation Bar. Despite numerous attempts to remove it, I haven't been successful.

Below is the HTML code snippet:

html:

<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">

<link rel="stylesheet" href="style.css"/>

<link rel="stylesheet" href="reset.css"/>

</head>

<body>

    <div class="header">

        <div class="navbar">
        <ul>
            <li><a>About</a></li>
            <li><a>Projects I've worked on</a></li>
            <li><a>Impossible List</a></li>
            <li><a>Contact</a></li>
        </ul>
        </div>
        <!-- end navbar div-->

    <div class="content">
    <p id = "title">Srikant Devarajan</p>

    </div>
    <!--end content div-->
</div>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum quidem quae magnam, facilis laborum minus provident. Earum ipsum quo voluptate cumque assumenda quia officiis, eaque suscipit error quae, maxime modi.</p>
<br>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum quidem quae magnam, facilis laborum minus provident. Earum ipsum quo voluptate cumque assumenda quia officiis, eaque suscipit error quae, maxime modi.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum quidem quae magnam, facilis laborum minus provident. Earum ipsum quo voluptate cumque assumenda quia officiis, eaque suscipit error quae, maxime modi.</p>
<br>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum quidem quae magnam, facilis laborum minus provident. Earum ipsum quo voluptate cumque assumenda quia officiis, eaque suscipit error quae, maxime modi.</p>
<br>


</body>
<!--end body-->
</html>
<!--end html-->

CSS used for styling:

@import url(http://fonts.googleapis.com/css?family=Roboto:400,300);
@import url(http://fonts.googleapis.com/css?family=Lato:300);

html,body{
    height:100%;
}
.header{ 
  background: url(images/background5.jpg) no-repeat center center fixed; 
   background-size: cover;
   height:100%;
}
.navbar{
    color:white;
    list-style: none;
    font-family: "Roboto";
    text-align:center;
    padding:20px;
    background-color:black;
    opacity:1.0;
    filter: alpha(opacity=70);
    position:fixed;
    top:0;
    widows: 100%;
}

.navbar ul{
    list-style: none;
}

.navbar li{
    display: inline;
    padding:70px;
    color:#CCCCCC;
}

.navbar a:hover{
    color:#fff;
}

.nav a{
    display:inline-block;
    padding:10px;
    opacity:2.0;
}
#title{
    margin-top:110px;
    font-size:70px;
    text-align:center;
    color:white;
    font-family:'Lato';
}

.content p{
    margin-top:70px;
    font-size:35px;
    text-align:center;
    color:white;
    font-family:'Lato';
}

Answer №1

Consider treating something as stationary, causing the browser to disregard its spatial presence. The gap between elements is affected by the margin-top within your title ID. Adjust this value to observe changes in the white space.

Update: Confirmed. The margin-top within your title ID is responsible for the spacing.

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 create a button with a background image that is also transparent?

Is it possible to set a background image for a button in HTML with a transparent background using CSS? Here is the HTML code I currently have: <button style="background-image: url('../images/example.png');"></button> ...

Setting up the CSS loader in a Vue.js project using webpack

I am currently working on a new vue-cli project and have successfully installed the Pure.CSS framework using npm install purecss --save. However, I am struggling to seamlessly integrate, import, or load the css framework into my project. I am unsure of whe ...

Strange gap between element and border on chrome

I noticed some strange spacing between the div borders and elements when I wrapped a few divs inside a container. This issue is only happening on Chrome and Edge, while Mozilla seems to display it correctly. My code includes the usage of Bootstrap along w ...

Tips for employing e.preventDefault within the onChange event handler for a select element

Is there a way to prevent the select tag value from changing using preventDefault? I have successfully prevented input from changing the value with event.preventDefault, but have not been able to do the same for the select tag. Here is an example code sni ...

The Firebase JQuery .on method is incrementally updating individual values in an array instead of updating them all simultaneously

I am trying to update the values of the orders placed by users on the Corporate's page without a refresh. I have implemented the jQuery .on method for this purpose. However, the values are being returned one by one from the array created for the order ...

Pages with embedded HTML code

Within the confines of locale/lang.json, there resides { "title": "Title", "image": "service-corporate_thumb-v2.jpg", "alt": "alt", "imageFooter": "Some caption %", "imageFooterCTA": "author", "imageFooterURL": "https://example.com/author", } ...

What's the best way to iterate through multiple objects within <td> tags using Vue.js?

I have an Array filled with multiple Objects, and now I am interested in iterating through each object as a <tr> within a <table>. I have successfully achieved this. However, some of these objects might contain nested objects. In such cases, I ...

"Consolidating into one large package, Less is compiled and bundled together

Is there a way to display only the CSS being utilized on a webpage after it loads, rather than serving all compiled .less files as one big .css file? In addition, I am interested in having a sourcemap of the .less files shown in the browser for debugging ...

I am unable to modify the suffix located beneath the price of the product

Although I am not well-versed in PHP, I managed to create a code to display parcel descriptions below the price of products. The issue I am facing is that my code is calculating too many decimal places and not displaying the default currency, which should ...

PHP mail function not working properly when ajax is used

On my MAC, I am attempting to utilize php mail with ajax implementation. I have simplified my code to just strings: In my .js file : function sendMail() { $('#sending').show(); $.ajax({ type:'POST', ...

The code for styling the borders of links is not functioning as expected

I'm currently in the process of creating a buttoned-link feature. The aim is to incorporate a border around the link with an outset style, while having the border-style change to inset when the link is active using a:active and border-style: inset. A ...

Clickable link unresponsive on parallax-enhanced webpage

Currently, I am utilizing Zurb foundation's Manifesto theme for creating a parallax scrolling landing page. The anchor tag is essential for the scrolling effect on this page, causing a conflict when regular anchor links are included. Here is the HTML ...

How can the "Search within page" feature locate words that are divided between different elements?

I need to present text in groups of a specific length while still being able to search for text that spans multiple groups on the page. Additionally, I want to include a character above each group. My current approach is as follows: body { marg ...

Linking an image to a database-stored value through a hyperlink

My goal is to give users the option to link their social media accounts such as Facebook and Twitter, with each link displaying an image that corresponds to the platform. The intention is for these images to direct them to the links stored in the database. ...

Error: Unable to access the 'resource' property as it is undefined

I am currently working on a project that involves fetching the latest 4 results from Craigslist using a query. Although I have successfully retrieved all the relevant information, I seem to be encountering an issue with loading the URL of the image from th ...

CSS experts caution that the addition of margin and padding can cause the screen to jump

When I apply margin and padding to this class, it starts glitching like in the second GIF. However, if I remove margin and padding everything works fine, but I do need them for styling purposes. What could be causing this issue and how can I resolve it? ...

- Prefixing with -webkit-transform and overlooking z-index

When using Safari 5.1.7 on Windows, I noticed that some rotated elements are overlapping others: However, when I test it on Firefox, Chrome, and IE, the issue doesn't occur: Is there a solution to prevent this overlap problem specifically on Safari? ...

Refreshing information within a table using Ajax Prototype

For my current project, I am utilizing PrototypeJS. I have implemented Ajax.PeriodicalUpdater to insert real-time data as required. However, I am facing an issue where the data is not getting replaced inside a specific table. Below is the HTML code snippet ...

Can the state and city be filled in automatically when the zip code is entered?

I have a form where users can enter their zip code, and based on that input, the corresponding city and state will automatically populate. These three fields are positioned next to each other within the same form. Here is an example of my form: $(' ...

Process the HTML content in PHP only after it has finished loading

When attempting to parse an HTML page using PHP with DOMDocument, I encountered an issue where a javascript on the page was updating an element after the DOMDocument loaded the page. This resulted in parsing the HTML before the elements were fully update ...