Position a div element at the bottom of the page, resembling the layout commonly seen on Pinterest

My goal is to implement a pinterest-inspired layout on my webpage. Each post by a user is contained within a div element. The layout, in a simplified form, can be represented like this:

Post with 11 likes    Post with 4 likes      Post with 1 like
Post with 9 likes      Post with 2 likes

Here is the CSS I utilized for the pinterest-style layout in HTML:

<div class="container">
<div class="post">Post1</div>
<div class="post">Post2</div>
<div class="post">Post3</div>
</div>

and for CSS:

.container {
column-count: 4;
column-gap: 10px;
margin:0 auto;   
padding:10px;
}

.post { 
display: inline-block;
margin: 0 0 1em;
width: 220px;
}

As I have multiple pages, I aim to include page numbers (which are hyperlinks to other pages) at the bottom of the page. Essentially, I am striving for a layout that appears as follows:

Post with 11 likes    Post with 4 likes      Post with 1 like
Post with 9 likes      Post with 2 likes

                     Page: 1 2 3 4 5 6 7 8 

I have implemented the following CSS:

#bottom{
position: fixed;
bottom: 0;
display: inline-block;
} 

The issue arises when the actual result looks like this:

Post with 11 likes    Post with 4 likes      Post with 1 like
Post with 9 likes     Post with 2 likes       Page: 1 2 3 4 5 6 7

Upon adding more posts, the layout transforms into this:

Post with 20 likes    Post with 7 likes      Post with 1 like
Post with 11 likes     Post with 4 likes      Page: 1 2 3 4 5 6 7
Post with 9 likes      Post with 3 likes      
Post with 8 likes      Post with 2 likes 

This occurs because the page believes that right below the "post with 1 like" there is the bottom of the page. How can I position my page number at the true bottom of the page rather than directly beneath a specific post?

Thank you all! I have resolved my issue by applying position:fixed to ensure all page numbers appear at the bottom. Initially, the numbers were condensed together due to being displayed in a PHP loop. By placing the bottom element outside of the loop, I successfully tackled the problem.

Answer №1

Check out this helpful guide on creating sticky footers.

While your code may technically work, it seems like using position: fixed may not achieve the effect you're looking for. This will simply keep the div at the bottom of the screen no matter what.

Additionally, using both display: inline-block and position: fixed together is contradictory. It's best to remove the former.

If your goal is simply to have the div appear below everything else on the page without being fixed to the bottom, consider removing it from the wrapping div and applying display: block.

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

Display a placeholder if image source is not working or missing

Looking to display a logo in next.js, my plan is to show a span if the logo is not available and hide it if it is. <div className='brand'> <Link href="#"> <img src="#" alt="UnSet" /> <s ...

Has Heroku caused your CSS Stylesheet to fail to load after deployment?

I've been struggling with understanding the asset pipeline in Rails 4 for some time now. I managed to figure out how to pre-compile assets, but after deploying my application, the CSS stylesheet doesn't seem to be updating. To confirm this, I ch ...

Font family experiencing compatibility issues with font face

The prominent "C" at the center of the page, as well as the H1 ('Choose The Right...) should be displayed using the "Pirulen" font-family. My initial attempt was to implement the traditional @font-face method for CSS, followed by a more advanced appr ...

Is it possible to include a relative URL with a different port number in a hyperlink?

Is it possible to link to a different port number on the same server without using Javascript or server-side scripting, especially if the hostname is unknown? For example: <a href=":8080">Check out the other port</a> (Note that this example ...

Unlocking the potential of # to craft interactive web pages

Lately, I've been seeing more and more websites like Twitter that have integrated AJAX into their layouts. One thing that has really piqued my interest is the inclusion of #! in URLs. I'm curious about how I can implement this on my own site or w ...

Display a different image while another image is in the process of loading

I am currently facing an issue with a div that has a background image set up as follows: <div class="carousel-image" style="background: url(img/background.gif) no-repeat center center;"> </div> Upon loading my webpage, there is a brief ...

A guide on iterating through carousel elements using Vanilla JavaScript

I am currently extracting data from The Movie Database and I aim to showcase the retrieved information on my webpage using a carousel card with 3 slides. Here is a summary of my progress so far, html, <div class="details"><!--Movie deta ...

prevent a text field from inheriting the Jquery.ui CSS styling

I am experiencing a minor issue where my text field is inheriting the CSS of the jquery.ui. This textfield is located inside a Jquery.ui tabs script, which applies its CSS by adding a class of the jquery ui tabs. How can I prevent this from happening and e ...

Looking to extract data from an HTML form?

In my HTML form, I am dynamically creating elements and setting their name and value attributes. When I try to access the value using document.formname.nameoftheelement.value, I receive an error stating that the value is undefined. I then attempted to us ...

jQuery Draggable Slider Scale

Seeking a draggable ruler (meaning it scrolls on double click) similar to the one showcased in the following link: I would greatly appreciate any assistance in finding a library that can provide this same functionality. View image here: https://i.sstatic ...

Clear all formatting and spacing from a numbered list

Is there a way to remove the indent and styling of an ordered list so that it appears like regular text? For example: 1. Item 1. Item [...] 1000. Item The desired appearance is as follows: 1. Item 2. Item [...] 1000. Item 100 Here is the code ...

In Firefox, the Ajax Call is failing to initiate a response automatically

I am currently working on developing a dynamically generated accordion with nested subaccordions. A filter function has been successfully implemented to manipulate the content on the page using Ajax. In order to achieve this, the following function has bee ...

Using Ajax and jQuery to dynamically insert an option into a datalist

I'm in the process of building a search box using Flask, MySQL, and ajax. I've managed to retrieve the search results in JSON format within the console, but now I want to dynamically add them to the options in my datalist element in the HTML. He ...

Alignment issues in buttons within Bootstrap

I'm facing an issue with the code snippet below <div className="row"> <div className="col-md-3"> <DateTimePickerComponent id="dateFrom" ...

Angular: Variable `app` has not been defined

I am working on a simple MEAN stack app and it is almost up and running, but I encountered an uncaught reference error when it tries to redirect to the index page. The server seems to be running fine and the browser displays "Loading..." as expected on the ...

Having difficulty transmitting data through a form with the POST method

I am struggling to get a simple form using POST method to pass input to the page. The file I am working with is named "agenda.php" and the code snippet for the form section is as follows: <?php /* includes lib */ include_once("lib.php"); ?> <!DOC ...

Storing information when an object is indexed in a for loop, to be retrieved later when

My JavaScript code includes an AJAX call that takes user input from a form and uses it to search for a JSON object. The matching objects are then displayed in a datalist successfully. Everything is working well so far, but now I want to extract specific f ...

Is there any effort being made to utilize jQuery for the css @media screen and (max-width: 768px) function?

Is there a solution for handling the @media screen and (max-width: 768px) in CSS? I have created a responsive navigation bar, but when I change the display property of an element from none to block on mobile screens, it also appears on larger screens. Is ...

Utilize AJAX in JavaScript file

I am encountering an issue with the following code: function inicioConsultar(){ $(function(){ $('#serviciosU').change(function(){ if ($('#serviciosU').val()!= "-1") { $.ajax({ url: "@Url. ...

scrollable list using bootstrap

<div class="panel panel-primary" id="result_panel"> <div class="panel-heading"><h3 class="panel-title">List of Results</h3> </div> <div class="panel-body"> <ul class="list-group"> &l ...