The webpage does not dynamically resize based on screen height

Encountered an issue with the excess space below the footer. Resolved it by implementing a jQuery sticky footer as CSS techniques were unsuccessful.

However, facing a problem with the main content of the webpage. Adjustment of .bg-photo's height impacts the footer's placement.

Elements within .bg-photo do not affect the footer's position.

Suspecting a possible HTML or CSS error causing this issue. Uncertain about the root cause.

Objective is for the page to auto-adjust to screen height without requiring manual scrolling to view the footer.

Check out the webpage:

Also, view the jsFiddle here: https://jsfiddle.net/mqfrnjaa/

Code snippets are available for immediate review.

Answer №1

One useful tool in a situation like this is the css property vh.

Depending on the browsers you need to cater to, you can use height: 100vh or vmin to adjust to the height of the viewport.

For more information on browser support, you can visit: https://caniuse.com/#feat=viewport-units

Answer №2

If you're looking to create a sticky footer without relying on plugins, it's definitely achievable with just CSS. Check out this example where I implemented a "sticky footer and header" using only CSS: here. You can easily add more content below the form and ensure that the page stretches all the way to the footer while keeping the content above it - see it in action here.

/**sticky-footer layout**/
body {
min-height: 500px;  
} 

.header,
#main,
.footer {
  -webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

.header {
height:120px !important; 
overflow:hidden;
background:#ffffff !important;
position:relative;
z-index: 10;
padding:0 !important;
opacity:0.9;
}

.footer {
height:100px !important;
background:#ffffff !important;
overflow:hidden;
opacity:0.9;
padding:0 !important;
}

#main {
  min-height:100%;
  margin:-120px 0 -100px;
  height:auto !important;

}

#main:after,
#main:before {
content:"";
display:block !important;
margin:0;
}

#main:before {
height:120px;
}

#main:after {
height:100px;
}

However, you may notice that the background container .bg-photo#main is positioned underneath the header and footer, which can cause some overlapping with the background image. To fix this, you can move the background to an inner div within the main section. I've demonstrated this scenario here: eventuality. Keep in mind that using vh units, like in the example below, may not work in all browsers:

min-height: calc( 100vh - 220px);   

Be cautious with this approach and consider using calc to account for the header and footer heights to ensure it works consistently across different 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

Iterate through the list elements by utilizing jQuery

I am working with HTML code that looks like this: <ul class="lorem"> <li>text</li> <li>text</li> <li>hello</li> <li>text</li> </ul> Can someone help me figure out how to loop through ...

Tips for ensuring the alignment of a table header and body once data has been loaded into it

I am currently developing an Angular 7 application where I am trying to populate a table with data retrieved from a web service. However, the issue I am facing is that the headers of the table do not align properly with the body content after loading data ...

What is the best way to confine the child elements within a parent element using CSS?

Check out my CSS and HTML code here: https://jsfiddle.net/z2cc11yk/ Here's the HTML: <div class="progressbar-container"> <div class="progressbar-text">125%</div> <div class="progressbar-progress" style="background-color: red; wi ...

ng-deep is causing changes in sibling components

Facing a challenge with Angular Material Design as I discovered the need to utilize ng-deep to customize the styling of an accordion. The issue is that when I use this method, it affects another accordion in a different section which is undesirable. Is th ...

Best practices for executing an asynchronous forEachOf function within a waterfall function

I've been working with the async library in express js and I'm encountering an issue when using two of the methods alongside callbacks. The variable result3 prints perfectly at the end of the waterfall within its scope. However, when attempting t ...

Preserve content from a hyperlink using JavaScript

How can I store a value to the cache using JavaScript when clicking on an anchor link? The code below sets up the dynamic content: <a align="left" href="projectoverview.html">Test Manager</a> I want to save the text "Test Manager" to the cach ...

How can I incorporate a dropdown menu into my website's navigation using Bootstrap 4 alpha?

This content is based on the Bootstrap v4 Alpha blog theme. I integrated it into a project but encountered issues when trying to add a dropdown menu to the navigation bar. Despite my attempts, the dropdowns did not appear as expected. I included the code ...

The functionality of the JQuery $.post method may be compatible with Firefox but may encounter issues when

I've encountered an issue with my website where certain functions that update the database using $.post work perfectly in Firefox, but fail to function properly in Internet Explorer. I'm struggling to identify the root cause of this problem. Here ...

Utilizing slug URLs effectively in Next.js

In my current project with Next.js, I am working on implementing "dynamic routes". The goal is to update the URL structure such that upon clicking, the URL should look like "myurl.com/article/55". To achieve this, I have utilized the following "link tag": ...

What could be the reason for the lower section of my website not being displayed?

I'm having an issue with a new div I added to the bottom half of my website - it's not showing up. Oddly enough, when I test the same code on a separate web page, it works fine. Can someone please take a look at the code and help me out? Thank yo ...

What is the best way to obtain an attribute name that is reminiscent of Function.name?

My objective is to securely type an attribute. For example, I have an object: const identity = { address: "Jackie" }; At some point, I will rename the address key to something else, like street_address. This is how it is currently implemented ...

Capturing an error within an asynchronous callback function

I am utilizing a callback function to asynchronously set some IPs in a Redis database. My goal is to catch any errors that occur and pass them to my error handling middleware in Express. To purposely create an error, I have generated one within the selec ...

CSS techniques for arranging images with varying sizes into a tiled layout

I have a collection of images that I want to arrange in a tiled layout, similar to the one shown in this image. These images consist of 3 photos with identical width and height, except for one which is larger and should occupy double the space compared to ...

Preventing text from wrapping around an image: tips and tricks

I've been struggling to prevent text from wrapping around an image on my webpage. Despite various attempts like enclosing the image and text in separate <div> elements, setting both the <img> and <div> to display as block, and even t ...

Using the $.each method instead of a traditional for loop

validateScaledIntegerNumberGridFields: function(frm) { var fields = $('.scaledInteger', frm); var result = true; $.each(fields, function(index) { var scale = $(this).data("scale"); ...

Menu icon in Next.js/React/Tailwind not triggering close action when clicked again, causing responsiveness issue

Hey there, I'm relatively new to working with Next.js and React. Right now, I'm tackling the challenge of creating a responsive navbar that toggles open and closed when clicking on the hamburger icon (and should also close when clicked outside th ...

Searching for and replacing text that spans across multiple nodes in HTML can be accomplished using C# programming language

Here is the HTML code to consider. The term 'response' was modified to 'reason', by removing 'sp' (<del> tag) and adding 'as' (<ins> tag), while also removing 'se' (<del> tag). <div &g ...

Having trouble implementing absolute css positioning on my custom composite button

I encountered a peculiar issue that I have managed to work around, but I am still curious about why it is happening. Below is the code for my Composite class: import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.clie ...

Error Encountered in Selenium WebDriver Javascript: Unable to locate variable: $

My goal was to utilize Selenium Webdriver to click a button on a web page. I was able to successfully achieve this using Chrome Developer Tools, however, I encountered a "can't find variable" error when executing Javascript code: IJavaScriptExecutor ...

Vue 3 App experiencing issues displaying Bootstrap 5 offcanvas component

I am currently working on integrating the new offcanvas feature of Bootstrap 5 into my Vue app. I have written the code, and after building the app, I am attempting to test it. However, I am facing an issue where the offcanvas menu is not visible. To kee ...