The body content is stopping halfway down the page, causing my footer to appear in the middle of the page

For some reason, I'm having trouble getting the footer to properly align at the bottom of the page. My body only seems to go halfway up the page. I tried wrapping everything in a main tag and setting a height on that, but it always ends up stopping at the same point. It's as if it's not recognizing the viewport properly and causing the issue. I'm new to coding, so any general advice on how to improve this would be greatly appreciated. Thanks in advance!

h1 {
  font-family: 'Dancing Script', cursive;
  text-align: center;
  font-size: 4vmin;
}

p {
  text-align: center;
  font-size: 3vmin;
}

li {
  font-size: 3vmin;
}

header {
  text-align: center;
  height: auto;
  width: auto;
  background-color: white;
  box-shadow: 2px 2px 2px 1px gray;
  margin-bottom: 2%;
  margin-right: 1%;
}

#main {
  position: relative;
  min-height: 100vh;
}
(...)
</footer>
  </div>

Answer №1

The reason for the footer not displaying correctly at the bottom is due to the line max-height: 100vh in #tribute-info. Once that line is removed, the footer will appear as intended.

It's important to note that the <header> tag should be within the <body> section, rather than being placed between the <head> and <body>.

Answer №2

I made some adjustments to the styles by removing the max-height property and relocating the header tag within the body tag.

#end
#pres
#prior
#tribute-info

h1 {
  font-family: 'Dancing Script', cursive;
  text-align: center;
  font-size: 4vmin;
}

p {
  text-align: center;
  font-size: 3vmin;
}

li {
  font-size: 3vmin;
}

header {
  text-align: center;
  height: auto;
  width: auto;
  background-color: white;
  box-shadow: 2px 2px 2px 1px gray;
  margin-bottom: 2%;
  margin-right: 1%;
}

#main {
  position: relative;
  min-height: 100vh;
}

#img-div {
  display: flex;
  margin: auto;
  justify-content: center;
  flex-direction: column;
  background-color: white;
  box-shadow: 0px 1px 2px 5px gray;
  max-width: 100vw;
  max-height: 100vh;
}

#image {
  box-shadow: 0px 1px 3px 5px gray;
  max-width: 70%;
  margin-left: 15%;
  margin-top: 1%;
}

#tribute-info {
  max-width: 100vw;
}

#young {
  background-color: white;
  box-shadow: 0px 1px 3px 5px gray;
}

#youngteddy {
  width: 85%;
  margin-left: 7%;
  box-shadow: 0px 1px 3px 5px gray;
}

#prior {
  max-width: 100vw;
  box-shadow: 0px 1px 3px 5px gray;
  background-color: white;
}

#priorimg {
  max-width: 70%;
  margin-left: 15%;
  box-shadow: 0px 1px 3px 5px gray;
}

#pres {
  max-width: 100vw;
  background-color: white;
  box-shadow: 0px 1px 3px 5px gray;
}

#president {
  max-width: 40%;
  margin-left: 30%;
  box-shadow: 0px 1px 3px 5px gray;
}

#end {
  max-width: 100vw;
  margin-top: 10%;
  box-shadow: 0px 1px 3px 5px gray;
  background-color: white;
}

#endimg {
  max-width: 100%;
  margin-left: 20%;
  box-shadow: 0px 1px 3px 5px gray;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600&display=swap" rel="stylesheet">
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<!-- Link to FCC Tester In top Left -->



<body>
  <header>
    <h1 id='title'>President Theodore "Teddy" Roosevelt </h1>
    <p>"Walk softly, and carry a big stick"</p>
  </header>

  <div id='main'>
    <div id='img-div'>
      <img id='image' src='https://www.buddenbrooks.com/pictures/70094_1.jpg?v=1593026042' alt='Theodore after hunting a cheetah'>
      <p id='img-caption'>Theodore Roosevelt kneeling in front of a cheetah</p>
    </div>
    <div id='tribute-info'>
      <div id='young'>
        <h1>
          <B>Teddy's Youth</B>
        </h1>
        <img id='youngteddy' src='https://image.pbs.org/video-assets/pbs/roosevelts/142017/images/mezzanine_487.jpg.crop.1920x1080.jpg' alt='Theodore Roosevelt as a young child'>
        <ul id=y list>
          <li><b>1858</b>: Theodore was Born to Martha and Bulloch Roosevelt</li>
          <li><b>1870</b>: Begins a physical regime that he continues throuout his life.
            <li><b>1876</b>: Begins study at Harvard University</li>
            <li><b>1878</b>: Meets his first wife, Alice Hathaway Lee
              <li><b>1880</b>: Graduates Harvard Magna Cum Laude, and joins the Republican Party</li>
      </div>
      <div id='prior'>
        <h1>Prior to his Presidency</h1>
        <img id='priorimg' src='https://publicradio1-wpengine.netdna-ssl.com/newscut/files/2015/07/roosevelt.jpg' alt='President Theodore Roosevelt during his time as a RuffRider standing beside his horse'>
        <ul>
          <li><b>1882</b>: Publishes first major literary work, 'The Naval War of 1812'</li>
          <li><b>1884</b>: Mother and Wife die of illness</li>
          <li><b>1888</b>: Publishes several books, including Life of Gouverneur Morris, Ranch Life and the Hunting Trail, and Essays in Practical Politics</li>
          <li><b>1889</b>: Starts as U.S. Civil Service Commissioner in Washington, DC</li>
          <li><b> 1895</b> Reigns from Civil Service to become Police Commisioner of New York.</li>
          <li><b>1897</b>: Appointed Assistant Seceratary of the Navy by William Mckinley</li>
          <li><b>1898</b>: Forms the 'Rough-Riders' and serves as a Colonel in Cuba during the Spanish-American War</li>
        </ul>
      </div>
      <div id='pres'>
        <h1>Becoming President Theodore Roosevelt</h1>
        <img id='president' src='https://upload.wikimedia.org/wikipedia/commons/d/df/Theodore_Roosevelt_circa_1902.jpg' alt='President Theodore Roosevelt'>
        <ul>
          <li><b>1901</b>: Serves as Vice President from March to September</li>
          <li><b>1901</b>: Becomes President in September, the youngest president ever.</li>
          <li><b>1902</b>: Begins anti-trust lawsuits to dissolve 42 monopolies</li>
          <li><b>1903</b>: Establishes Pelican Island, FL as first federal bird reserve and Begins building Panama Canal</li>
          <li><b>1904</b>:Re-elected president, established United States Forest Service</li>
          <li><b>1905</b>:Establishes Wichita Forest, OK as first federal game preserve. Establishes Russo-Japaneese Peace Treaty</li>
          <li><b>1906</b>: Established many national parks. Visited Panama Canal, becoming the first president to do so. Won the Nobel Peace Prize.</li>
        </ul>
      </div>
      <div id='end'>
        <h1>End of an era</h1>
        <img id='endimg' src='https://allthatsinteresting.com/wordpress/wp-content/uploads/2016/10/pointing.jpg' alt='Theodore Roosevelt giving a speech after just being shot'>
        <ul>
          <li><b>1909</b>: End of his Presidency. Departs for year-long African safari with son Kermit</li>
          <li><b>1910</b>: Accepts Peace Prize in Norway. Publlishes "African Game Trails", and returns to New York from travels around the globe.</li>
          <li><b>1912</b>:Pressured to accept Presidental nomination. Becomes presidential cantidate of the "Bull Moose" or Progressive party. Deliveres famous speech despite being shot in the chest before it.</li>
          <li><b>1913</b>: Publishes "Theodore Roosevelt - An Autobiography and History as Literature and Other Essays"</li>
          <li><b>1914</b>:Embarks on an expedition to explore an uncharted tributary of Amazon River, which he nearly dies during. Publishes two books named "Through the Brazilian Wilderness" and "Life Histories of African Game Animals"</li>
          <li><b>1918</b>: Publishes "The Great Adventure".</li>
          <li><b>1919</b>: Dies in sleep at Sagamore Hill of a coronary embolism (arterial blood clot), age 60</li>
        </ul>
      </div>
    </div>
    <footer>
      <div id='tlink-container'>
        <p>Intrested in learning more about the Bull-Moose?
          <a id='tribute-link' target="_blank" href='https://www.britannica.com/biography/Theodore-Roosevelt'>Click here</a>
      </div>
    </footer>
  </div>

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

How to prevent npm from being accessed through the command prompt

I recently began working on a ReactJs project. However, I am facing an issue where after starting npm in Command Prompt, I am unable to enter any text. Should I close the cmd window or is there a way to stop npm? You can now access your project at the fol ...

Is it possible to create an input field exclusively for tags using only CSS?

I am currently facing some limitations with a website I am managing. Unfortunately, I do not have the ability to incorporate additional libraries such as custom jQuery or JavaScript scripts. My goal is to customize an input field for tags so that when us ...

The correct method for including a CSS file in a Vue.js application

How can external CSS files be properly added in a Vue.js Application? I have come across multiple methods for adding CSS files in a Vue.js Application. One suggestion is to use the following code: <link rel="stylesheet" type="text/css" href="/static/b ...

Rotate object within HTML table

I have a simple data structure as shown below: [ { "ClientId": 512, "ProductId": 7779, "Date": "2019-01-01", "Quantity": 20.5, "Value": 10.5 }, { "ClientId": 512, "ProductId": ...

Video Autoplay within an image carousel - A seamless integration

I need assistance embedding a YouTube video as the fourth item in a slideshow on my website, www.serenitygardenrooms.com. The slideshow should play the first three images and then autoplay the video before moving on to the next image. However, the code sni ...

Ways to hide the loading spinner on a web browser

As the owner of a Comet application, I am facing an issue with long polling requests being sent via AJAX immediately after the page loads. These requests take a while to complete, causing browsers like Safari and Chrome to display their loading icon even t ...

Fluid overlap of divs in Bootstrap framework

I am currently in the process of making style adjustments to a website at One specific change I've made is adding a top bar image. However, I've encountered an issue where the top bar graphic overlaps the navigation when the page is resized too ...

Create a 2x2 HTML table where the first row remains undivided

I am working with an HTML table that is 2x2. Within this table, I am trying to achieve a layout where the first row consists of only one cell that spans the full width of the table, without being divided into two parts. ------- | | ------- | | | -- ...

What is the best way to show and hide text by toggling a link instead of a button?

I need help with toggling between two different texts when a link is clicked. I know how to achieve this with a button in JQuery, but I'm not sure how to do it with a link. <h1>Queries and Responses</h1> <p>Query: What is the larges ...

Using HTML as an argument in a JavaScript function

Within a variable, I have stored an entire HTML page. $body = $myhtmlpage; <a onclick="openWin('<?php echo htmlspecialchars(json_encode($body)) ?>');" href="javascript:void(0);"> Click </a> I also have this JavaScript functio ...

When attempting to select an option from the dropdown menu, I encounter an issue where the

My code is not behaving as expected. Whenever I click on the child elements, the dropdown changes to display: none. I am encountering an error when clicking on the input frame and displaying:none. How can I resolve this issue? I would like to be able to ...

I am having trouble with my image not resizing properly within the flexbox when using height and max-height properties

In my flexbox setup, I have two columns, each taking up 50% of the width. My goal is to insert a large square image in the right column, with its height being determined by the contents' height in the left column. (Additional content will be added to ...

Issue with Bootstrap columns being misaligned on mobile devices

On my website, I've implemented a Bootstrap Grid design with three columns under the container-fluid BS attribute, along with .row .no-gutters. While the boxes are perfectly aligned in the desktop view, they stack vertically on mobile and tablet devi ...

Utilizing consistent CSS styles across VueJS components

Currently tackling a VueJS 2 project and facing issues with scoped styling when cleaning up the code. My setup involves 3 components that share similarities, prompting me to utilize mixins for consolidating the code into one file. Each component makes use ...

When using Javascript's querySelector, often times it returns null

Here is the HTML code I am working with: <button class="pop-btn"> Pop </button> While I was able to style this button using CSS, I encountered a problem when trying to select it in Javascript: const Population_div_Button=document. ...

Trouble with DevExpress ASPxButton: Some Properties Fail to Update

It's been a while and I'm facing a tough challenge. I need to change the image source of an ASPxButton from the code behind, but it seems like the height, width, and border style are getting lost in the process (resulting in an image with its own ...

Tips for maintaining the original ng-click initialized value as the ng-init value after the page is refreshed

My ng-repeat feature includes buttons for liking and disliking images. The problem I'm facing is that each time the page refreshes, the count of likes and dislikes gets reset to the initial value set by ng-init. How can I maintain the incremented lik ...

React Hamburger Menu not working as intended

I am facing an issue with my responsive hamburger menu. It is not functioning correctly when clicked on. The menu should display the navigation links and switch icons upon clicking, but it does neither. When I remove the line "{open && NavLink ...

In JavaScript, a "switch statement" retrieves a test value from a "input type text" by accessing the value using getElementByName.value

Attempting to test 7 possible values for the variable 'a' by passing it to a function from user input in seven 'input type text' boxes, then checking each value individually with clicks on 7 'input type image' elements. Howeve ...

What could be the reason for the absence of margin on the top and bottom

.separator { border: 1px solid #000000; margin: 10px; } <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>Separator</title> </head> <body> &l ...