Achieving a bottom-aligned div in ASP.NET using CSS

How can I ensure that a div always stays at the bottom of the page, even when the user scrolls down? Here is the CSS code I have:

#CenterPanel {
    position: absolute;
    bottom: 0px;
    left:0;
    width: 100%;
    height: 85%;
    background-color: green;
}

.CenterPanels {
    position: relative;
    border: 2px solid #303641;
    width: 28%;
    height: 30%;
    margin: 10px;
    float: left;
    border-radius: 10px;
}

And here is the ASP.NET code for 10 divs and the center panel:

<div id="CenterPanel">
    <div class="CenterPanels">1</div>
    <div class="CenterPanels">2</div>
    <div class="CenterPanels">3</div>
    <div class="CenterPanels">4</div>
    <div class="CenterPanels">5</div>
    <div class="CenterPanels">6</div>
    <div class="CenterPanels">7</div>
    <div class="CenterPanels">8</div>
    <div class="CenterPanels">9</div>
    <div class="CenterPanels">10</div>
</div>

The desired appearance should be like this: https://i.sstatic.net/lel3P.png

But instead, while scrolling, it looks like this: https://i.sstatic.net/bGohX.png

The green section should stay at the bottom, but it's not working as intended.

I want to achieve this using only CSS, without relying on JavaScript or other methods. I have tried using `bottom: 0px;` and `bottom: 0%;` but no luck. Any suggestions?

Answer №1

Simply include overflow:auto in your container div style.

#CenterPanel {
  position: absolute;
  bottom: 0px;
  left: 0;
  width: 100%;
  height: 85%;
  background-color: green;
  overflow: auto;
}
.CenterPanels {
  position: relative;
  border: 2px solid #303641;
  width: 28%;
  height: 30%;
  margin: 10px;
  float: left;
  border-radius: 10px;
}
<div id="CenterPanel">

  <div class="CenterPanels">
    1
  </div>
  <div class="CenterPanels">
    2
  </div>
  <div class="CenterPanels">
    3
  </div>
  <div class="CenterPanels">
    4
  </div>
  <div class="CenterPanels">
    5
  </div>
  <div class="CenterPanels">
    6
  </div>
  <div class="CenterPanels">
    7
  </div>
  <div class="CenterPanels">
    8
  </div>
  <div class="CenterPanels">
    9
  </div>
  <div class="CenterPanels">
    10
  </div>
</div>

Answer №2

Have you checked if this is present in your footer section? If it is, consider adding the CSS property "position: fixed;" to make the footer sticky.

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

Error message: The ScriptResource failed to load

This issue is puzzling... I have an ASP.NET 3.5 web application that consists of a content page and a master page, with a few user controls added on the content page. In total, there are four controls on the page - two custom controls and two Ektron CMS ...

The read more button is not functioning properly when used in conjunction with the <br>

Can someone help me debug an issue I'm facing with my code? I have created an HTML tab that contains multiple DOM elements, each with a "Read More" button. Everything works fine when it's just plain text, but as soon as I add tags within the p ...

Obtain the caller of the controller method (external third-party web service)

Is it possible to retrieve the URL of a third-party webservice calling my controller method? I have noticed that things like Request.Current.Url only refer to my own URL (/someController/someAction/). The third-party webservice is sending HTTP POST data t ...

Achieve a floating right alignment of an unordered list navigation using CSS without changing

I am currently implementing a jquery navigation system which can be found at this link: http://css-tricks.com/5582-jquery-magicline-navigation/ My goal is to have the navigation bar float to the right without changing the order of items (e.g. home, contac ...

Utilizing ASP.NET 2.0 authentication service with a non-web client

I've been developing a .NET 2.0 winforms application that communicates with an ASP.NET 2.0 website using forms authentication. The web.config file has the authentication service enabled, and I've conducted some tests to verify that I'm able ...

_problem with text formatting in bootstrap 4 template

I am having trouble formatting a 2-line text Right now, it appears like this https://i.sstatic.net/nJdOB.png I would like it to display like this https://i.sstatic.net/DflAK.png This is the HTML code I'm using with bootstrap <label for="check ...

disappearance of background image at bootstrap breakpoint

Hey there, I'm diving into a new journey in web design and I've encountered my first newbie issue. I'm attempting to place an image and text side by side on my web layout, but as soon as the breakpoint hits below 560px, the image disappears ...

"Explore stunning images with the power of JavaScript in our

My question involves a div containing five images, displayed in order as [1] [2] [3] [4] [5]. I am looking to create a JavaScript script that will automatically rearrange the images to display them as [2] [3] [4] [5] [1], then [3] [4] [5] [1] [2], and so o ...

JavaScript: How can I remove it when I click anywhere on the webpage with onClick?

A challenge I'm facing involves creating a form with an input field that changes its border color when clicked. My goal is for the border to return to its original color when clicking anywhere else on the page. -HTML <form action=""> ...

The CSS filter "progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=80)" is not functioning properly in Firefox

Trying to apply a filter effect using CSS but encountering issues in Firefox: progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=80 ) opacity: 0.5; -moz-opacity: 0.5; Any s ...

Is there a way to modify a button's aspect ratio when it is clicked?

Currently, I am utilizing the MUI v5 AppBar to craft a navigation bar with Tabs. My aim is to have the background of the Tab blend seamlessly with the main page background upon being clicked, as illustrated here: https://i.sstatic.net/e4bDn.png However, a ...

Troubleshooting problems when using SELECT with Angular, ASP.NET Web API, and EF Code First

I am currently encountering an issue with making a SELECT work seamlessly with Angular, ASP.NET Web API v2, and Entity Framework Code First. Within my setup, I have two straightforward objects - Products and Categories, outlined with the following models: ...

Tips for removing two specific "th" elements from a table that is generated dynamically

I have a challenge where I need to remove 2 specific elements from a table depending on which delete button is clicked Check out the code snippet below : <!--HTML--> <button type="button" class="collapsible">Manage Formulas</button> < ...

Issue with importing styles within a media query

I am having trouble importing a style that is based on a media query. When I try to import the styles, it doesn't seem to work. However, if I directly include the styles within the media query itself, they show up on the page. For reference, you can ...

What is the best way to set the keyframes CSS value for an element to 0%?

Would like to create a progress indicator div using CSS animations? Check out the JSBin link provided. The desired behavior is to have the div width increase from 30% to 100% when the user clicks on stage3 after stage1, rather than starting from 0%. Althou ...

What are some ways to integrate ngAnimate into ngTable for improved visual effects?

Hey everyone, I've been working on a project where I'm trying to merge ng-animate and ng-table. I created a plnkr to showcase my progress: http://plnkr.co/edit/EfZF5oWb9qzGvOIbAhtX?p=preview Despite injecting both directives into the scope and ...

Elements with absolute positioning are preventing drag events from executing

Struggling to create a slider and encountering an issue. The problem lies in absolute items blocking slider drag events. I need a solution that allows dragging the underlying image through absolute positioned items. Any ideas on how to achieve this? MANY T ...

The results in the grid are displayed in a horizontal layout, rather than a

My grid results are not rendering as desired, appearing horizontally instead of in two columns. Attached is my current CSS and a screenshot of the issue for reference. Any suggestions on how I can achieve the layout shown in the screenshot below? .grid ...

No Response or Value Change When Clicking ASP.NET C# Button

I have created a basic website using ASP.NET C#. It functions properly after I click [RUN] in Visual Studio. However, once I uploaded it to my web hosting server, nothing happens when the button is clicked. The "Label1" remains unchanged. It appears that ...

How can you ensure an image is centered properly when padding is applied?

Is there a way to center an image without affecting padding around it? Check out this sandbox for reference HTML <div class="imageParent"> <figure id='img-div'> <img class='image card' ...