Dealing with a straightforward problem in CSS: ensuring minimum height of 100% with margin

I'm seeking advice on how to make a div have a minimum height of 100% while also having a margin-top of 15px. My goal is for the div to reach the bottom of the screen without causing scrollbars, but when the content exceeds the screen size, I want it to automatically expand beyond the screen limit and trigger scrollbars. Here's my current code snippet:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body, html{height:100%; margin:0;}
body{background:#AAA}
#main{position:relative; width:970px; margin:0 auto; border:solid 1px #666; background:#FFF; margin-top:15px; min-height:100%;}
</style>
</head>

<body>
<div id="main">
try duplicating this content until it does not fit in the box 
</div>
</body>
</html>

Answer №1

Try using this CSS code snippet to help anchor the div element at the bottom of the page:

#main{position:fixed; bottom : 0px; width:970px; margin:0 auto; border:solid 1px #666; background:#FFF; margin-top:15px; min-height:100%;}

Answer №2

After much experimentation, I have discovered a fix: Implement the latest CSS3 box-sizing rule on the body with padding-top:15px; eliminate the margin-top from #main, and voila! The issue is resolved in all modern browsers.

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

Exploring the methods of connecting with data-checked and data-unchecked attributes in Angular

Utilizing a toggle switch, I am able to determine what text to display in the div by utilizing html attributes such as data-checked and data-unchecked. In addition, I have an Angular pipe that translates all texts on the website based on the selected lang ...

Is Javascript necessary for submitting a form to a PHP script?

In my current project, I am working on a page to edit information in a database. While I know how to create the form in HTML and the PHP script that runs on the server, I am facing a challenge with JavaScript. My understanding of JavaScript is limited, and ...

Minification of CSS - Vuetify

While working on my Nuxt project with Vuetify, I noticed that the page source is quite lengthy with 26k lines of code, most of which is generated by Vuetify's CSS. On comparing it with other pages, I see shorter code with difficult-to-read CSS. Is the ...

What is the method in PHP to send an HTML file along with a value in response to a POST request?

I have a PHP file where I want to include a dropdown list and submit button. The dropdown list should display filenames for the user to choose from. Once the user selects a filename from the dropdown list and clicks the submit button, the PHP file should r ...

How can I utilize PHP to generate several tables within a single database?

I need some guidance on creating multiple tables within the "new" database. I'm curious if it's possible to include PHP code inside the query to generate table names dynamically. Any help would be greatly appreciated. Thank you in advance. <? ...

Discovering tags that are isolated and encasing them with specific tags

After researching Beautifulsoup, I am looking to identify <a> elements that are not nested within <p> tags and then wrap them with <p>, but I am unsure of the process <p><a href="example1.com">example1.com</a></p> ...

Verify the accuracy of the color value on a web page using Selenium in Java

As a beginner in using Selenium with Java, I encountered an issue related to a symbol in my connected class turning green. I needed to assert whether the symbol actually changed its color. Below is the code snippet that I used: Boolean connectionSymbolG ...

I am in need of help with coding so that my entire webpage is displayed properly even when I resize it to the smallest width. Additionally, I need assistance with making

Having some issues with making my personal website work correctly. I'm planning to share images of how it looks at different widths - largest width and smallest width. Also, here are the links to my website here and to my GitHub code here Seeking gui ...

Keep track of the toggled state and prevent any flickering when the page is reloaded, all without the

After extensive searching, I couldn't find exactly what I needed. Therefore, I decided to utilize cookies to remember the toggled state of a div whether it's hidden or visible. However, I encountered an issue where there is flicker happening as t ...

Having trouble displaying a single result in CodeIgniter using PHP and MySQL?

Embarking on my CodeIgniter journey, I am eager to display a percentage result in the view of my project. Once this issue is resolved, the path ahead will be much smoother. Here is the model function snippet: <?php public function _construct() { ...

How can the Nth-child CSS property be modified to exclude HTML elements with the display property set to none?

I have a basic gallery set up using an unordered list. <h1>Projects</h1> <hr> <!-- Projects displayed as an unordered list --> <ul class="gallery"> <li class="item residential"> <img ...

Incorporate Thymeleaf's HTML using the powerful JavaScript framework, jQuery

I am facing an issue where the Thymeleaf rendered HTML code is not being displayed by the Browser when I try to insert it using JavaScript. $('<span [[$ th:text#{some.property.key}]] id="counter" class="UI-modern"> </ ...

adjust the vertical size of a specified container

I am attempting to have the green div fill the height regardless of the content in the yellow div. Both the green and yellow divs are contained within the grey div. Refer to the following code for clarification: http://jsbin.com/ofelov/1/edit (As for th ...

Inline phone form input using Bootstrap

I'm attempting to design a nested Bootstrap grid for a phone number input. The concept is to have a label for the phone number, and it's fine if on smaller screens the "label" and "phone group" stack. However, I want to maintain the inline layout ...

Tips for toggling the visibility of a flexbox-styled popup using jQuery

I am trying to implement a popup on my website and I want to use flexbox styling for it. I have the necessary scss mixins for flexbox properties, however, I encountered an issue. The problem arises when I try to hide the popup using display: none, as the ...

Add a .handlebars or .hbs file to an HTML document

When visiting the emberjs.com homepage, you will find an example of a todo list using Ember.js and Handlebars.js. Within the todo list, there is an extension for a .hbs file. I am curious - what exactly is a .hbs file? And how can I include a .hbs script ...

Guide on using jQuery to replace the applied css of an aspx control

My dilemma revolves around an AspxFileManager. I am attempting to distinguish a file when it is loaded by adding a class that places a border around the element. My initial attempt using .attr('style', 'border: 10px!important'); was uns ...

Gather information using the nth-child or css_selector methods in selenium using python

Exploring the realms of Python and Selenium, I have set my sights on data extraction from . Specifically, I am interested in retrieving the market cap and 24-hour volume values. The HTML snippets for these are outlined below. <div id="__next"& ...

Retrieve the text/value from an input field in an external HTML file, then auto-refresh it at regular intervals

I am encountering some issues with extracting text from a URL and populating a form input field with the retrieved data. The code functions properly using a div element, but I would prefer to utilize an input text field instead. Below is the jQuery code t ...

I'm having trouble with my paragraph tag fulfilling its responsibilities

Let's get straight to the point. Here is the code snippet that's causing me some issues: <p id="mainBlock"> <img src="/icons/128x128.png" id="icon"> <h3>App name</h3> <span id="version"></span> < ...