Container Fluid height not fully supported in ASP.Net webpage

Despite attempting a solution from this source, I am still encountering an issue.

My ASP.net page layout looks like this:

   

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="ToolDesign.Home" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Availability Test</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- Bootstrap -->
        <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="/Scripts/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/Scripts/bootstrap.js"></script>

        <style>
      body {
          position: relative; 
      }
      #section1 {padding-top:50px;height:500px;color: #fff; background-color: #009688;}
      #section2 {padding-top:50px;height:500px;color: #fff; background-color: #673ab7;}
      #section3 {padding-top:50px;height:500px;color: #fff; background-color: #ff9800;}
      #section4 {padding-top:50px;height:500px;color: #fff; background-color: #00bcd4;}
      #section42 {padding-top:50px;height:500px;color: #fff; background-color: #009688;}


      <!-- make page stretch -->
      html, body {
        height: 100%;
    }
    .container-fluid {
        height: 100%;
        overflow-y: hidden; /* don't show content that exceeds my height */
    }
    .body-film {
        min-height: 100%;
        overflow-y: hidden; /* don't show content that exceeds my height */
    }
      </style>
    </head>
    <body data-spy="scroll" data-target=".navbar" data-offset="60">

       <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>                        
          </button> 
          <a class="navbar-brand" href="#">Availability Tool</a>
        </div>
        <div>
          <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="nav navbar-nav">
              <li><a href="#section1">Home</a></li>
              <li><a href="#section2">Availability Test</a></li>
              <li><a href="#section3">Monitoring</a></li>
              <li><a href="#section4">About</a></li>
            </ul>
          </div>
        </div>
      </div>
    </nav>    

    <div id="section1" class="container-fluid">
      <h1>Home section</h1>
      <p>Greeting text</p>

    </div>
    <div id="section2" class="container-fluid">
      <h1>Availability section</h1>
      
    </div>
    <div id="section3" class="container-fluid">
      <h1 style="text-align: center; font-size: 300%;; vertical-align: middle; line-height: 90px; margin-top: 100px;">Soon..</h1>
    </div>
    <div id="section4" class="container-fluid">
      <h1>About</h1>
      <p>Tool version and team name</p>

    </div>


    </body>
    </html>

The problem lies in the height not filling the entire screen, as indicated in the screenshot below:

https://i.sstatic.net/gTbwc.png

I am using the most recent version of Bootstrap 3.3.7

Answer №1

I encountered a similar issue in the past when trying to implement a "sticky footer" with Web Forms. The problem typically revolved around the form tag that is automatically included in Web Forms project templates. Assuming your markup and CSS are correct otherwise, you can attempt the following solution:

html, body, form
{
    height: 100%;
} 

Understanding the challenge associated with the "form" tag in Web Forms (often overlooked in our CSS selectors), here is a fundamental approach for creating sticky footers:

https://css-tricks.com/couple-takes-sticky-footer/

I have not had the opportunity to test your code yet, but I did notice inline CSS, which should be moved to an external style sheet. It is recommended to set up a basic form and master page for testing purposes - keep the content minimal on your test page and confirm its functionality.

Answer №2

(This post is written on behalf of the original poster).

The Solution

The problem stemmed from some issues with the css stylesheet. To begin with, we need to address the section styles:

  #section1 {padding-top:50px;height:500px;color: #fff; background-color: #009688;}
  #section2 {padding-top:50px;height:500px;color: #fff; background-color: #673ab7;}
  #section3 {padding-top:50px;height:500px;color: #fff; background-color: #ff9800;}
  #section4 {padding-top:50px;height:500px;color: #fff; background-color: #00bcd4;}
  #section42 {padding-top:50px;height:500px;color: #fff; background-color: #009688;}

It's important to note that the height:500px values should be changed to 100% in order for each section to fill the screen properly.

Additionally, the form tag needs to be included in the body style block, along with moving all relevant CSS properties into this section:

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

Finally, unnecessary CSS can be removed and the revised code will look like this:

     html, body, form {
            height: 100%;
            position: relative;
        } 
  #section1 {padding-top:50px;height:100%;color: #fff; background-color: #009688;}
  #section2 {padding-top:50px;height:100%;color: #fff; background-color: #673ab7;}
  #section3 {padding-top:50px;height:100%;color: #fff; background-color: #ff9800;}
  #section4 {padding-top:50px;height:100%;color: #fff; background-color: #00bcd4;}

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 causes the flex div to inherit the full width of its parent div?

I'm having trouble understanding why a flex div always occupies 100% width of its parent element. Consider the code snippet below: #wrapper { width: 100%; height: 100px; background: green; } #flex { color: white; display: flex; ...

What is the best way to apply a background color to an element temporarily?

Check out the following code snippet: $('html,body').animate({scrollTop: -20 + $('.clsname').offset().top}); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> ... (additional scrip ...

Troubleshooting a Problem with Binding Knockout Select to JSON Response from Web API in ASP.NET

Hey, I'm in need of some assistance. I've come across what seems to be a simple issue, but for some reason, I just can't seem to figure it out. Here's the situation: I am fetching a list from Web.API using EF public JsonResult Retrie ...

What is the best way to ensure a NavBar stays at the top of the page when it is not collapsed?

I have integrated a NavBar using Bootstrap 5, which functions flawlessly. However, I am facing a specific issue that I haven't been able to resolve yet: When a user increases their screen size to <300%, it triggers the collapse button to appear. I ...

Selecting a pair of radio buttons to toggle the visibility of different div elements using JavaScript

I've been working on two radio button categories that control the visibility of different input fields. I'm making progress, but I'm still struggling to get it to work perfectly. Below are the images for reference: The combination of &apos ...

Managing Requests for IP and Domain Names Using Angular Frontend and Spring Boot Backend

I am currently developing a Spring Boot application with an Angular frontend that acts as a simple login gateway. This login system utilizes encrypted credentials and click verification to authenticate users. I aim to customize the functionality based on w ...

Customize hover effects for MuiCheckbox

For some reason, my checkboxes are displaying a circle on hover that I want to remove. https://i.sstatic.net/62TLL.png I attempted to make overrides in MuiTheme: export const MUI_THEME = createMuiTheme({ overrides: { MuiCheckbox: { root: { ...

The CSS style tag does not function in Safari

I am trying to dynamically load background images using CSS based on the display resolution using the @media keyword. This method works perfectly in Firefox and Chrome, but unfortunately, it does not seem to work in Safari. Is there something I might be ...

Tips for embedding multiple video players on a single HTML page

I'm currently experiencing an issue with the YouTube API. I am in the process of developing a website where I want a video to automatically play when I open its corresponding image. The code I used initially worked successfully: <script> // 2. ...

The JavaScript file is functioning properly when loaded locally, but encounters issues when loaded from the server

My Android webview app is giving me some trouble. I recently moved a JavaScript file online so that I could easily make updates that would immediately affect the app without requiring an update. However, when I try to load the script from the server where ...

What methods can I use to identify the selector for this element?

After pinpointing the specific element in Google Chrome using inspect element, what kind of path or syntax should I use to apply a method to this element? The hierarchy for the element is outlined below: html body div#contentDiv div#searchFormDiv ...

An error occurred while trying to create a user instance of SQL Server because the process for the user instance failed to start. As a result, the connection will be terminated

After trying to include a "service based database" (.mdf) in an asp .net project, I attempted to create an entity framework model file (.edmx). However, I encountered the following error message: There was a problem connecting to the database. It seems ...

Having trouble with applying CSS conditionally in React JS with Typescript?

I'm currently facing an issue with my code where I want the Box to stay highlighted with a black border when clicked. Here's the snippet: interface BigButtonProps { onClick(): void; Title: string; Description?: string; startIcon?: R ...

Guide on efficiently transferring extensive data sets from controller to the view in ASP.NET MVC

Is there a way to handle loading more than 2 MB of data (15000 records) using Ajax in ASP.net MVC? When the Ajax call retrieves data larger than 2 MB, the response is null, but it works perfectly for data less than 2 MB. I've made adjustments to my w ...

Is it possible to include the contents of an .ics file and provide a link to it in HTML, all without relying on JavaScript?

The content of an .ics file is quite simple: BEGIN:VCALENDAR VERSION:2.0 PRODID:-//appsheet.com//appsheet 1.0//EN CALSCALE:GREGORIAN METHOD:PUBLISH BEGIN:VEVENT SUMMARY:Invitation from <<USEREMAIL()>> to talk about <<[MeetingTopic]>> ...

Verifying that the class name prefix aligns with the folder name using Stylelint

Currently, I am utilizing the "selector-class-pattern" rule from stylelint. My chosen pattern enforces the ECSS naming convention. The specific rule configuration is outlined below: "selector-class-pattern": ["^[a-z]([a-z0-9]){1,3}-[A-Z][a-zA-Z0-9]+(_[A-Z ...

Input text into search box to transfer value to URL without using the equal (=) symbol

Currently, my website allows users to search by entering a value in the URL after /search/. For instance, searching for "hello" can be done by visiting www.mywebsite.com/search/hello. Now, I am looking to implement a simple search box that functions simil ...

What is the CSS technique for displaying text overflow after displaying only two lines within a div?

Currently working on a webpage design where I am looking to display text overflow using ellipsis within a div. However, my requirement is to display two lines of data in the div before handling the text overflow. I prefer not setting a fixed height for t ...

Ensure that the page is edited before being shown in the iframe

Is it possible to remove a div from an HTML page within an iFrame? The code below fetches an HTML page and displays it in an iframe. Is there a way to remove the specified div from the fetched HTML page? <script type="text/javascript"> (function(){ ...