Make a div element align to the bottom position

I have searched for a solution to this issue on SO, but none of the suggestions were effective in all browsers. Therefore, I am now turning to jQuery to help me achieve the desired result.
My goal is to position the div at the bottom of the HTML page, rather than at the bottom of the screen.

So far, I have experimented with CSS only

clear: both;

min-height: 6%;

position: fixed;

bottom: 0;

Edit
Here's my current CSS:

html, body {

margin: 0px;

padding: 0px;

height: 100%;

}

#footer {

 width: 100%;

 height: 6%;

 position: absolute;

 bottom:0px;
 left:0px;
}

#content {

float: left;

width: 59.5%;

height: 83%;

position:relative;

}

#news {
 z-index:2;
}

<html>
 <div id="content">
  <div id="news"> </div>
 </div>
 <div id="footer"></div>
<html>

Answer №1

Looking for a sticky footer solution? I think this might be what you're after.

Check out the jsfiddle demo.

You can find the sticky footer code on this website.

The key is to implement the sticky footer and then customize it to fit your needs by styling the #wrap element.

Answer №2

To make elements align to the bottom of the page, set the height of body and html to 100%. Create a wrapper for the entire body with position: relative and height: 100%, then place the element inside this wrapper.

<html
    <body>
        <div id="body-wrapper">
            <div id="bottom"></div>
        </div>
    </body>
</html>

You can achieve this with CSS:

body, html {
    height: 100%;
}

#body-wrapper {
    height: 100%;
    position: relative;
}

#bottom {
    position: absolute;
    bottom: 0px;
    left: 0px;
}

View the difference when using a wrapper:

Answer №3

To ensure the div stays at the bottom of its container, apply position: absolute; and bottom: 0px; to it. The wrapping element must also have position: relative; for proper alignment.

Answer №4

When styling your webpage, remember to consult the CSS document:

An element with a fixed position is placed in relation to the browser window. An absolutely positioned element is located relative to the first parent element that has a position other than static. If no such element is found, the containing block is used.

Source: http://www.w3schools.com/css/css_positioning.asp

Therefore, it is recommended to utilize position:absolute for optimal results.

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

"Sharing values from a multidimensional array in Javascript with a Java servlet - a step-by-step

I have managed to save the values from textboxes into a multidimensional array in my Javascript code called records (as shown below) and now I want to send this array object to my servlet page. However, I am unsure of how to access and retrieve the compl ...

What is the method for performing a spelling check on every property within an array of Objects?

I'm working on a program that takes a user input as an argument and then searches for a similar match in an array of objects. The array of objects is retrieved from a database. When the user inputs a name, the search criteria should find objects with ...

Combining strings within a string after a specific word with nested Concatenation

In a given string variable "str," I am looking to concatenate another string between "InsertAfterMe" and "InsertBeforeMe". str="This is a string InsertAfterMe InsertBeforeMe" s1="sometext" s2="soMoreText" aList=[1,2,3,4,5] The concatenated string shoul ...

Creating a Vue.js component that integrates a Bl.ocks.org graph

I'm a rookie in the world of D3 and I am trying to implement this cool d3 element into my Vue.js component. However, I've encountered an issue with the periodic rotation that I require not functioning properly. It seems to work initially but then ...

Implement a function in a prototype that can be accessed globally, regardless of the module it is contained in

Trying to extend the functionality of the Array prototype in Typescript (1.8) through a module. The modification to the prototype is being made in utils.ts file: declare global { interface Array<T> { remove(obj: any): void; } } Arr ...

Guide to implementing a radial gradient using CSS on a cairo surface in gtk4

I am attempting to create a circular shape on a Gtk4 GtkDrawingarea using CSS. The goal is to then save the circle as a PNG file upon clicking on it. However, I am encountering difficulties in transferring the drawing (gradient) from the drawing area to a ...

Appending an empty <li> tag has no effect

I'm facing an issue with this loop where it always generates empty <li></li> tags. Can anyone help me understand why this is happening and suggest a solution? For reference, the loop runs 2 times (verified). function a(){ for (var i ...

Angular struggles to display carousels using templates

I've been working with Angular and UI Bootstrap components to create a carousel using the templateUrl argument for slide rendering. However, I've encountered some issues along the way. Firstly, nothing seems to appear on the page when I run it, a ...

Continue to receive fresh activities for finished requests in rsocket

Given a scenario where an Rsocket endpoint is set up using Spring, @MessageMapping("chat.{chatId}") Flux<Message> getChats(@DestinationVariable String chatId) { Mono<Chat> data = chatRepository.findById(chatId); ...

Is it feasible to utilize VAST for delivering HLS streams? Can m3u8 files be incorporated into VAST tags for delivery?

We are integrating a video player that supports VAST pre-roll, mid-roll, and post-roll video ads. I'm wondering if it's feasible to include m3u8 files in VAST tags? I've reviewed the vast specification and examples, but haven't come ac ...

GraphQL and Relay.js issue: Error Message: Field "id" is expected in "Node"

It appears that the discrepancy lies in naming conventions between my schema.js file and the database field. The 'id' field in the schema is actually named differently in the database. var classroomType = new GraphQLObjectType({ name: 'Cl ...

Error: Issue encountered while attempting to download file using express.js res.download

After creating an xlsx file with the help of the json2xlsx npm module, I am utilizing the res.download(file) functionality in express.js to facilitate the download process. For more information, please refer to: Download a file from NodeJS Server using Ex ...

Changing the direction of the cursor to move opposite of the mouse's input

I'm currently working on a unique webpage with an unconventional navigation method. The concept involves the cursor moving in the opposite direction of mouse movement input. To achieve this effect, I decided to hide the actual cursor and use JavaScri ...

Angular 4: Harnessing the Power of Pipe Chaining

While using the *ngFor directive, I am attempting to apply multiple pipes but I'm encountering difficulties getting it to function properly. <tr *ngFor="let order of orders | filter:filter; let i=index | paginate: {itemsPerPage:7 , currentPage:p}" ...

Enhancing Database Queries with Multiple PHP Drop Downs

Take a look at this image of my database table -> MySQL-Table I am working on developing a search page with drop-down selectors to filter through the last 8 columns in my table. The goal is for these drop-down selectors to allow users to select multipl ...

Is it possible to create an AngularJS and jQuery Calendar Directive that activates by clicking on a Bootstrap glyphicon?

I have successfully created a directive for my calendar using AngularJS and jQuery. The datepicker pops up when the user selects the input box. Now, I am attempting to allow the user to click on Bootstrap's 'glyphicon glyphicon-calendar' to ...

Tips for creating SCSS shorthand for an Array value color within a property

I've got a SCSS file containing an array of color values. export const COLORS = { transparent: 'rgba(0,0,0,0)', primary: '#09596e', primary01: '#317D92', primary02: '#6BADBF', primary03: '#97C6D2& ...

Allowing a certain amount of time to pass before executing a method

I'm familiar with using setTimeout and setInterval to delay the execution of a method, but I am facing a specific issue. I am working on implementing a card game where three CPU players take turns with a 500ms delay between each turn. Below is the cod ...

The issue arises when Node.js fails to identify the input fields that were dynamically inserted into the form

I came across a question similar to mine, but I found it challenging to apply the solution to node js. In my project, users can add items to a cart by clicking on them, which are then dynamically added to a form using jquery. However, upon submission, only ...

Tips on incorporating a changing variable into a JavaScript Shader

I have successfully created a primitive sphere using THREE.SphereGeometry and applied a displacement shader to give it a bumpy effect. My goal now is to animate the scale of the bumps based on input volume from the microphone. Despite my efforts, I am stru ...