What could be causing the white gap beneath my homepage?

I have successfully created a website that utilizes buttons for navigation, with everything working smoothly except for the homepage. On the homepage, there seems to be excessive white space below all the content. I attempted to fix this by setting overflow to hidden, but this caused the button used for navigation to be blocked. My goal is to make the height of the first page equal to the user's screen height and allow scrolling if some content cannot fit within the initial view.

For reference, here is the codepen link: https://codepen.io/Lukie/pen/eWobYa

// JavaScript functions for scrolling behavior
function scrollDown() {
  $(".home").removeClass("slideInLeft");
  $(".home").addClass("slideOutUp");
  
  $(".content").css("visibility", "visible");
  $(".content").removeClass("slideOutDown");
  $(".content").addClass("slideInUp");
}

function scrollUp() {
  $(".home").removeClass("slideOutUp");
  $(".home").addClass("slideInDown");
  $(".home").css("visibility", "visible");
  
  $(".content").removeClass("slideInUp");
  $(".content").addClass("slideOutDown");
}
body {
  background-color: white;
  overflow-x: hidden;
  transition: all .6s ease-in-out;
}

/* CSS styles for various elements */
.home {
  top: 0;
  visibility: visible;
}

.content {
  position: absolute;
  top: 0;
  visibility: hidden;
}

.logo {
  margin: 4% 0 14% 0;
}

.downBtn {
  position: relative;
  color: orange;
  transition: all .3s ease-in-out;
}

.downBtn:hover {
  transform: scale(1.2);
  cursor: pointer;
  transition: all .3s ease-in-out;
}

.upBtn {
  position: relative;
  color: black;
  margin: 4% 0 0 8%;
  transition: all .3s ease-in-out;
}

upBtn:hover {
  transform: scale(1.2);
  cursor: pointer;
  transition: all .3s ease-in-out;
}

.car {
  transform: scale(.8); 
}

p {
  font-family: Raleway;
  font-size: 14px;
  line-height: 180%;
  color: black;
  margin: 0 22% 10% 18%;
  padding: 10px;
  border-left: 2px solid #191a1c;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Home Page -->
<div class="container-fluid home animated slideInLeft">
  <!-- Tesla Logo -->
  <div class="row">
    <div class="col-md-12">
      <a href="https://www.tesla.com/" target="_blank"><img class="logo mx-auto d-block" src="http://resizeimage.net/mypic/TkJbULc2TToQO5jb/Nyv35/tesla.png" alt="Tesla Logo"></a>
    </div>
  </div>
  <!-- Scroll Down Button -->
  <div class="row">
    <div class="col-md-12 text-center">
      <i class="downBtn fa fa-5x fa-angle-down" aria-hidden="true" onclick="scrollDown()"></i>
    </div>
  </div>
</div>

<!-- Content Page -->
<div class="container-fluid content animated slideOutDown">
  <!-- Scroll Up Button -->
  <div class="row">
    <div class="col-md-12 text-left">
      <i class="upBtn fa fa-5x fa-angle-up" aria-hidden="true" onclick="scrollUp()"></i>
    </div>
  </div>
  <!-- Car Image -->
  <div class="row">
    <div class="col-md-12">
      <img class="car mx-auto d-block" src="https://www.tesla.com/tesla_theme/assets/img/modals/model-select-models.png?20160811" alt="Tesla" </div>
    </div>
    <!-- Paragraph about Tesla -->
    <div class="row">
      <div class="col-md-12">
        <p>Tesla’s mission is to accelerate the world’s transition to sustainable energy. Since our founding in 2003, Tesla has broken new barriers in developing high-performance automobiles that are not only the world’s best and highest-selling pure electric
          vehicles—with long range and absolutely no tailpipe emissions—but also the safest, highest-rated cars on the road in the world. Beyond the flagship Model S sedan as well as the falcon-winged door Model X sports utility vehicle, we plan on launching
          our new Model 3 sedan later this year at a base price of $35,000 that we expect to truly propel electric vehicles into the mainstream.</p>
      </div>
    </div>
  </div>
</div>

Answer №1

The reason for this lies in your utilization of the CSS property visibility. By switching it to display : block and display : none, you can refer to this resource on the disparities between visibility:hidden and display:none.

Answer №2

To achieve the desired results, it is necessary to utilize the display attribute in this scenario. For more in-depth information about the display property, visit the following website: https://www.w3schools.com/cssref/pr_class_display.asp

Your code snippet:

.content {
      // Add other relevant code here
      display : none;

    }

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

Modifying the font style of a Flot bar chart

Issue I am facing a challenge with adjusting the small numbers displayed on top of a bar chart created using Flot. It seems like these numbers are generated through canvas, making it difficult for me to customize them to match the styles I have set for th ...

There was an issue encountered while parsing the JSON data - "SyntaxError: Unexpected token . was caught."

Encountering an error in Chrome while parsing JSON data. The JSON sample can be found at this link. It is valid JSON and the server is sending the correct Content-Type value (application/json). Uncaught SyntaxError: Unexpected token . Firefox shows a sli ...

Skewed top-left border surrounds the element with a dashed design

I'm looking to achieve a border effect similar to the one shown in the image linked below: https://i.sstatic.net/a4hCQ.jpg Here is the code I have tried so far: <p>Some Text</p> p{ -webkit-transform: perspective(158px) rotateX(338deg ...

Resolving the Conflict Between Jquery and require.js

Exploring the concept of jQuery no conflict, I referred to the explanation provided in this article Using private jquery with RequireJS - issue after optimisation However, upon loading my page with additional configurations like the ones below: ...

Investigating Jquery Flip Card Issues

Looking to create a set of flip cards using HTML, CSS, and jQuery. Currently facing an issue where only the first card is flipping when clicked. Any suggestions on how to modify the jQuery code to make it work for all cards would be highly appreciated. C ...

Challenges with Image Placement and Alignment

Having trouble with the sizing of my image in the skill portion of my website. The clouds and mountains look fine, but for some reason, the image isn't the same size. Additionally, the text "full stack developer" is not centered under my name anymore ...

The multiline feature of tooltip on mat-table cell is malfunctioning

I adjusted the mat-tooltip to be displayed as multiline using the following style in the global CSS: .mat-tooltip-class-here { white-space: pre-line !important; } Interestingly, this formatting works on span and button elements but not on mat cells. ...

The nightmare of Parent-Child Inheritance in JQuery/CSS is a constant struggle

Having difficulty implementing specific JQuery effects into a Bootstrap framework due to its extensive CSS causing issues. Created a test file named testjquery.html connected to a stylesheet defining a hidden element and activating the fade in of this ele ...

implement a JavaScript function for sprite toggling

I have been working on a JS/jQuery function to switch the position of an icon sprite. I have successfully created the following code: $('.toggle-completed').mouseup(function(){ var sp = ($(this).css('background-position')); $(this).css ...

Enhancing CSS to create a more visually appealing loading spinner

I am completely new to CSS and I've been attempting to customize the CSS in the angular-loading-bar module to create a more visually appealing loading spinner. Currently, I have a square spinner that rotates in the center of the page, with a black bor ...

Verify if an element is not being hovered over using jquery

I've been experimenting with creating my own tooltip, and while it works well, I noticed that if you move the mouse quickly out of the div, the tooltip remains visible. The problem seems to be that the tooltip follows the cursor closely, making it fr ...

Turn off the following navigation link in the Bootstrap wizard

I am working on a bootstrap wizard and I need to find a way to disable the next navigation link under certain conditions. Does anyone have suggestions on how I can achieve this using jQuery, CSS, or any other method? <div id="rootwizard"> ...

What advantages does KnockoutJS offer over AngularJS?

Can KnockoutJS offer a unique feature that rivals or exceeds those of AngularJS? ...

Issue with the height of sections in the active menu

While the set-up below is functional for content within section height limits, it fails when exceeding the limit causing overflow. Adding "display: table" or "overflow: hidden" to fix the overflow issue affects the menu's active state behavior. Sett ...

Showing text following a specific number of search outcomes

When pulling products from my database for a search page query, I need to include some specific text after the 6th and 12th pagination results on each page. If there are fewer than 12 results, the text should only appear after the 6th result. How can I imp ...

jQuery shorthand conditional statements

I currently have a jQuery function that is triggered by two separate buttons. $("#btnSearch, #btnDirectorSearch").click(function () { The construction of the HTML output within this function relies on which button was clicked. To accomplish this, I am ut ...

A step-by-step guide on submitting a CSV file with Ajax along with additional form information

Imagine you have an HTML form with input fields for Name, Location, Address, and Family members (to be uploaded as a CSV file), along with a Submit button. However, when you click on submit, the data from the CSV file is not being passed to the PHP script. ...

Adjusting the transparency of one element and rotating another element that are the same size

This issue is driving me nuts: I'm attempting to rotate the border of a circle element and simultaneously adjust the opacity of the circle overlay when a user hovers over it. However, in my current setup, only the opacity changes: <div id="main-c ...

Creating dynamic properties in JavaScript based on another object is a powerful way to manipulate data

In my current scenario, I am faced with the task of creating a new object named result based on an existing object called source. This new object must contain all properties from source, and also include additional "methods" named after the properties to ...

Learning how to replace the alert function with Bootbox

I am currently working on a form that posts to a MySQL database. I want to replace the alert function triggered by the Malsup jQuery Form Plugin with the one created by the Bootbox plugin. Even though both plugins are functional, I struggle to integrate th ...