What is the enigmatic void hovering beyond the bounds of the HTML layout?

I am facing an issue with a div container that contains four spans.

<body>
  <main>
    <div>
      <span>One</span>
      <span>Two</span>
      <span>Three</span>
      <span>Four</span>
    </div>
  </main>
</body>

The div is positioned absolutely to touch the bottom of the screen and the text-align property is set to justify for evenly spaced spans inside. However, when I try to make the spans have a height of 100%, a strange white space appears at the bottom which seems unrelated to the layout flow. I suspect it might be related to the div:after pseudo-element but I am unable to figure out the cause.

* {
  padding: 0;
  margin: 0;
}

main {
  position: relative;
  height: 100vh;
  width: 100%;
  background-color: rgb(45, 45, 65);
  text-align: center;
}

div {
  position: absolute;
  top: 50%;
  left: 25%;
  right: 25%;
  bottom: 0;
  text-align: justify;
  display: block;
}

div:after {
  display: inline-block;
  width: 100%;
  content: '';
}

span {
  background-color: rgb(25, 25, 45);
  box-sizing: border-box;
  display: inline-block;
  font-size: 1em;
  padding: 10px;
  height: 100%;
}

span:hover {
  background-color: white;
}

Is there something I am missing about how :after works or is this a glitch? What could be causing the unexplained white space at the bottom?

For reference, you can view the problem here: http://codepen.io/anon/pen/qdpERR?editors=110

Answer №1

By simply including overflow: hidden; in the styles of the main element or its parent, you can effectively remove any excess white space at the end of the webpage.

If you are interested, check out this link: http://codepen.io/TibicenasDesign/pen/yNpyLr?editors=110

Uncommenting overflow: hidden; or box-sizing: border-box will do the trick and eliminate that annoying white space at the bottom of your webpage.

Personally, I always use box-sizing with border-box so it slipped my mind momentarily - but it turns out to be a great solution!

Answer №2

Consider incorporating box-sizing:border-box as an alternative solution, especially if there is padding applied to the link elements.

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

Steps to create a clickable button wrapper label in React

Contained within the components below: <CheckboxGroupLabel htmlFor={option.label}> <FormCheckbox onClick={() => onChange} key={option.label} defaultChecked={defaultChecked} {...rest} /> {option.value} ...

Is there a way to redirect components within a different component without altering the URL?

Imagine you have an Angular 5 project with routings, such as /home, /landing-page, etc. Let's say your landing page has the URL localhost:4200. On this page, you want to create a login panel with fields for username and password, a sign in button, and ...

Choose Your Price - Price Grids

I need to incorporate two sets of pricing columns into a website. The first set is for regular car cleaning prices, while the second set is for larger cars with slightly higher prices. My idea is to have two buttons at the top – one for regular cars and ...

Link Formatting Instructions

https://i.sstatic.net/PZVKx.png I am trying to style the right element to look like the one in the image, but when I apply the 'pull-right' class, it unexpectedly affects the width of the element below it. <a class="pull-right">My link< ...

What is the best way to eliminate the blue color from a Boostrap 5.3 accordion item when it is opened?

As shown in these two images, I am looking to remove the blue color and blue border when opened: https://i.sstatic.net/vOIna.png https://i.sstatic.net/7eLfK.png <div class="accordion-item"> ...

Tips for isolating html and js code?

After following a tutorial to write the program, I attempted to separate the HTML code from JS but encountered issues. Some lines of JS code are connected to the database as parameters, and when I split the HTML and JS codes, it no longer functions. Does ...

Tips for fixing image distortion on screens smaller than 576px in a Bootstrap 5 responsive layout

view image description here see image details here <div class="banner"> </div> .banner { background-image: url(../img/portada.png); height: 20rem; /* Setting height because it is empt ...

Parsing JSON multiple times to extract data on the top 10 games from Twitch's API

Hey there! I have a little coding challenge for you. The current code below is only fetching the first channel from the JSON. My goal is to fetch all the streams and display them in a grid format with three streams per row. Can you help me achieve this? (B ...

Can someone help me locate the file using the inspect element feature?

Today, I encountered a small issue on my website that I wanted to fix. Although I was able to make the necessary changes using Inspect Element, I couldn't locate the file where it needed to be changed. The website in question is gesher-jds.org/giving. ...

An issue with HTML5 canvas arcs: distortion occurs in the arc shape

Below is the code I'm using to create an arc on an HTML5 canvas. <!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="1000" height="550" style="padding-top:20px;border:1px solid #d3d3d3;"> Your browser does not support t ...

What is the best way to include Google Calendar in a div container while ensuring it is responsive?

I'm currently working on the layout of a website that features a slideshow of images at the top, followed by an embedded Google Calendar. I've encountered an issue with the responsiveness of the Google Calendar within its designated div container ...

Ways to style a div identifier within a div group

<div class="content"> <div class ="imgs"> <a href="#"><img src="images" alt="some_text" width="250" height="210"></a> </div> <div class = "compu"> <div id="titulo">text</br></div> ...

What is the best method for converting Unix time to a readable date

<el-table-column label="Time Created" prop="create_time"></el-table-column> https://i.stack.imgur.com/aoLjf.png The timestamp data from the backend is in milliseconds format (e.g. 1527150668419) and is stored as create_time property in this.i ...

The HTML calculator is failing to show any output

My HTML calculator is facing issues with displaying input and results. I want to maintain the existing layout and design of the calculator while fixing this problem. The calculator was created using only HTML code to keep it simple for integration into an ...

Dividing HTML and JavaScript using Vue

Is there a way to separate HTML from data/methods in VueJS to avoid having one long file with both? I tried moving the contents of my <script> section into a new file called "methods.js" and importing it using: <script src="methods.js"> Note ...

Applying media queries to incorrect screen sizes

My media query seems to be behaving oddly. @media only screen and (max-width: 1200px) { .tool-panel { margin: 0px 24px 0px 0px; } } It is getting applied at 1183.20px instead of 1200px. This discrepancy is consistent across all browsers ev ...

Grow an element starting from its center without being limited by the boundaries of a div

I'm faced with a puzzling issue that I believe has a simple solution, but it seems to be eluding me at the moment. Essentially, I have a div containing an image as its background. Upon clicking this div, I want another circular div (created using bord ...

Customers can access the order details after completing a Paypal payment

My hotspot system requires users to pay through PayPal for Internet access, after which they are redirected back to the hotspot and given a code. The issue I'm facing is that many users are forgetting or failing to write down their code. To address th ...

Ensuring consistent height for CSS divs and buttons

Is there a way to ensure that my buttons have the same height as the questlist_item? Even after applying the same CSS height:auto;, the heights remain unequal. Any suggestions on how to achieve equal button heights? Thank you! var questlist = [{...}]; ...

Enhancing page accessibility through the implementation of shortcuts

Greetings to all members of the community! I am currently in the process of improving a website by implementing better accessibility practices. I have some concerns regarding a page that displays a large number of repeated result blocks, each containing ...