Dynamically Allocating Page Heights

I am tasked with creating an ASP.NET MVC page that will display a template of controls. The controls will be retrieved from an XML file. One issue I am facing is that the number of controls is not fixed, so the page height needs to be dynamic. Our site has a blue background and the page itself should be white. However, when I add many controls to the page, they end up overlapping on the blue background. I have tried setting the height using "height:85%" and "height:auto", but it doesn't seem to work. Below is my CSS code:

#main-content 
{
    padding:0px 0px 25px; 
    width:747px;
    position:relative;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    height:85%;
}

The HTML file structure looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="ctl00_Head1">
<link href="../Content/customize.css" rel="stylesheet" type="text/css" />
</head>
<body> 
    <div id="main-content">          
        <div>
            <div style='left:20px;top:80px; position:absolute;' >Name</div>
            <div style='left:80px;top:80px; position:absolute;' ><input id='Text1' type='text' value='Mr.Temp'/></div>
            <div style='left:20px;top:210px; position:absolute;' ><input id='Chk1' type='checkbox' value='Check One' checked/>Check One</div>
            <div style= 'left:20px;top:340px; position:absolute;' ><input id='Radio1' type='radio' value='OptionOne' />OptionOne</div>
            <div style='left:260px;top:80px; position:absolute;' ><image id='image1'/></div>
            <div style= 'left:118px;top:340px; position:absolute;' ><input id='Radio1' type='radio' value='OptionTwo' checked/>OptionTwo</div>
            <table border='1' style='width:400px;'><caption>TempTable</caption>
                <tr align='left' valign='top'>
                    <th align='left' valign='top'>Name</th>
                    <th align='left' valign='top'>Age</th>
                    <th align='left' valign='top'>Address</th>
                </tr>
                <tr align='left' valign='top'>
                    <td align='left' valign='top'>Mr.A</td><td align='left' valign='top'>30</td><td align='left' valign='top'>TownshipA</td>
                </tr>
                <tr align='left' valign='top'>
                    <td align='left' valign='top'>Mr.B</td><td align='left' valign='top'>40</td><td align='left' valign='top'>TownshipB</td>
                </tr>
                <tr align='left' valign='top'>
                    <td align='left' valign='top'>Mr.C</td><td align='left' valign='top'>50</td><td align='left' valign='top'>TownshipC</td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>

Please provide guidance on how to address this issue with some examples.

Regards,
Indi

Answer №1

Your issue stems from the use of absolute positioning.

Elements that are absolutely positioned do not contribute to the body's height with padding.

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 causing the align content property to not function as expected in this situation?

Is it expected for the flex items of the .center-section-container to be closer together when using this property? They do not seem to be affected at all. I have applied flex wrap so the items are now in different lines but too far away from each other, I ...

Encountering difficulty in reading a session variable when accessing it through Ajax, however, the variable is successfully retrievable when called from the controller in ASP.Net

I have implemented a method within the controller to retrieve the value of a session variable. However, when I attempt to call this method from Ajax jQuery, I am unable to obtain the value. Interestingly, if I try to read the session value from another met ...

Create an HTML document with a bottom section that shows up on every page when printed

I am currently working on creating a footer for an HTML file where the requirement is to have the footer displayed on each printed page. I came across a solution that fixes specific text to every page that I print. Here is the code snippet: <div class ...

The layout of the table is not formatted in a single continuous line

I recently implemented the material-ui table and noticed that the header has a multiline break space. I am looking for a way to make it display in a single line instead. Is there any solution for achieving this using material UI or CSS? Feel free to chec ...

Utilize PHP to generate a table from data

I successfully created a table using information retrieved from my database, and everything is displaying as intended. However, I am facing an issue where adding a background color applies it to every row in the table. How can I add a background color wit ...

Firefox and IE are unable to make changes to cssRules

To update existing global CSS rules, I access the document.styleSheets property to locate the rule and make modifications. The selector can be modified by accessing the selectorText property. Sample CSS code: <style type="text/css"> .class { ...

The ASP.NET MVC controller did not receive the JSON object properly due to some missing properties

I am facing an issue when trying to pass a JSON object to my ASP.NET MVC controller. The JSON is set in JavaScript in this way: jsonChildren = '{ "childImproItems" : [{ "Theme":"tralalali" }, { "Theme":"tralalali" }]}'; ... $.ajax({ ...

How can I delete the header and footer on a personalized homepage design?

After crafting a unique home page/landing page for my website that stands out from the rest, I've come across an issue. The header and footer are appearing on this new page, but I only want to display what I specifically coded. I attempted using Site ...

Issues occur with Google visualization when the screen is resized

When I resize the browser, an error code google-visualization-errors-8 appears in my Google chart's CSS. https://i.stack.imgur.com/4LX1C.png What could be causing this error to occur? Note: I am redrawing the graph every time the screen is resized. ...

No specified margin at the top of the website's header section

My task was to design the header section of a webpage to resemble this desired webpage look. I started by creating a "header" tag as a container and added a navbar within it. To display the items, I used an unordered list with CSS adjustments for a horizon ...

Adding a CSS class to an HTML element using JQuery

I have a collection of tabs, and I want to dynamically add an <hr> element with the class "break-sec" when a certain class is active. This element should be placed within a <span> element with the class "vc_tta-title-text" after the text. Here ...

Arrange the bootstrap columns in a grid layout both vertically and horizontally adjacent to one another

I need help with displaying my columns in this specific layout https://i.stack.imgur.com/2hzju.jpg Code <div class="row"> <div id="id-orders-stats" class="col-md-6 col-sm-6"> </div> <div class="col-md-6 col-sm-6 stats-box"&g ...

Place the blockquote in the middle, but maintain the text's alignment to

I recently designed a webpage using Bootstrap and CSS. My main goal is to have my two blockquotes centered on the page while keeping the text left-aligned (which is the default behavior for the selected classes in Bootstrap). To see the full code, take a ...

Tips for defining a relative path in the base URL with AngularJS

Encountering an issue with AngularJS routes related to file paths. The folder structure is as follows: js -> Angular -> css -> Bootstrap -> index.html Routes work fine when hosted on a server like IIS. However, copying and pasting the direct ...

What could be causing my jQuery function to not correctly update the class as specified?

Presented is a snippet of script that I execute at a specific moment by echoing it in PHP: echo "<script>$('.incorrect-guesses div:nth-child(2)').removeClass('empty-guess').addClass('incorrect-guess').text('2' ...

Creating an Innovative Grid Design with Varying Column Widths for Each Row

Seeking advice on achieving a specific layout using HTML. I have attempted to use HTML tables but struggled with creating rows with varying columns. Does anyone have recommendations for grid tools that may be more helpful? Thank you ...

The jQuery toggle functionality seems to be malfunctioning

I have created a form that should toggle (hide and show) with the click of a button, but for some reason it's not working. Can someone please take a look at my code below and let me know what I'm doing wrong? $(document).ready(function () { ...

Shape with a dark border div

Having some trouble with creating this particular shape using CSS border classes. If anyone can assist in making this black box shape using Jquery, it would be greatly appreciated. Check out the image here. ...

Using a pseudo-element after to center CSS content

Although there are numerous posts discussing this topic, my situation is unique. In my case, I have a collection of colors represented by circles. When I click on a circle, I add content in the form of a check mark by including a class selector with an af ...

Having trouble getting my AngularJS animations to work, hitting a roadblock

Here is the code I've put together for you to review, with no official purpose in mind. I just saved this code to use at a later time. <script> var apps = angular.module('myApp', ['ngAnimate']); //header apps.cont ...