Using CSS to position two divs at the bottom-right corner of the page by using the `position: absolute` property

Currently working on creating an uncomplicated chatbox with a header using CSS. My aim is to position the chat at the bottom and right of the page. I've experimented with the following:

float: right;
bottom: 0;
position: absolute;

Although this aligns it to the bottom, it doesn't place it correctly to the right. Below is my complete code:

CSS

#chatbox {
    height: 360px;
    width: 320px;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    float: right;
    bottom: 0;
    position: absolute;
}
.chatheader {
    font-family:'PT Sans';
    background: #999;
    width: 322px;
    height: 36px;
    color: #fff;
    text-align: center;
    padding-top: 15px;
}

HTML

<div class="chatheader">chatboxheader</div>
<div id="chatbox">

</div>

If you'd like to see the code in action here's a demo link DEMO I'm keeping it simple for now to focus on alignment before enhancing the design. Appreciate any assistance provided! Thank you!

Answer №1

To have both the chatheader and chatbox display at the bottom right of the page, I made a few adjustments to the code. I placed both elements within a div container.

Here is the updated HTML:

<div id="chat-container">
    <div class="chatheader">chatboxheader</div>
    <div id="chatbox"></div>
</div>

And here is the CSS:

#chat-container {
    right: 0;
    bottom: 0;
    position: absolute;
}

The right:0 property ensures that the element stays at the far right of the page.

You can view the updated fiddle here.

Answer №2

Check out the live DEMO here

Here is the HTML code:

#chatbox {
    height: 360px;
    width: 320px;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
}
.chatheader {
    font-family:'PT Sans';
    background: #999;
    width: 322px;
    height: 36px;
    color: #fff;
    text-align: center;
    padding-top: 15px;
    float:right;
}
.chatMain {
    position:absolute;
    bottom:0;
    right:0;
}

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

The PHP navigation is being obscured by the image gallery

I have implemented a PHP navigation system for my website using the code below: * { margin:0; padding:0; list-style:none; text-decoration:none; } img { position: absolute; top: 10px; left: 40%; } ul#navi { float:left; background:#31 ...

What is preventing my code from being recognized as a valid XML file?

Encountering an error indicating that this code snippet is not valid within an XSL file. This is the only feedback provided by the document system. While this code is a part of a larger document, I decided to isolate the issue to determine if it lies in ...

Use CSS elements selectively on specific pages within Mkdocs

Currently, I am utilizing mkdocs in conjunction with the material theme to produce documentation. I am interested in incorporating section numbers on specific pages. To achieve this, I have implemented the following method for generating section numbers. ...

Setting the row property of a frameset using CSS: a step-by-step guide

What is the best way to set the frameset row property using css or jquery for various browsers? ...

Upload several files sequentially in a form on a website using Selenium with Python

I need to automate the process of inputting multiple files from a folder into a website and running an online job for each file. Currently, I can only input one file at a time using this code snippet. from selenium import webdriver url = "http://www.exam ...

Issues persisting with vertical alignment in table cells on Firefox browser

I've successfully managed to vertically center the contents of .onesizechart in Chrome and Safari, but I'm facing issues with Firefox and IE. Interestingly, the contents of .homepage-sizechart are displaying correctly, leading me to believe that ...

Is there a way to activate an event listener specifically for clicking on an image?

Presently, my code consists of a div element that holds two images. The first image has a z-index of 1 and appears behind the second image. I am looking to implement an event listener that will be triggered only when the first image is clicked. Interestin ...

Creating a div that reaches the bottom of a scrollable webpage in ASP

Struggling to position my sidebar at the bottom of the page without using fixed positioning, as I don't want the buttons to scroll along with it. I simply want the background to extend to the bottom of the scrollable page. Despite trying various "solu ...

Is it possible to create a mouse-following effect with lighting using Javascript

Recently, I've been honing my Javascript skills and decided to create a follow-mouse function. After successfully implementing it, I started brainstorming a new concept that I'm unsure is achievable. Is there a way to develop an "orb of vision" ...

What is the best way to conceal panels while a bootstrap is being utilized?

I have been working on a bootstrap panel that consists of three panels: Panel 1, Panel 2, and Panel 3. The functionality of this panel is working correctly under normal circumstances. My Approach: Clicking on Panel 1 should display its content while hid ...

Tips for ensuring a flexbox stays within the bounds of its container and doesn't exceed the available space

I am in the process of developing a modal that needs to be centered on my page and expand organically, but only up to a specific width and height limit. Using flexbox, I have successfully centered this modal (.modal) on the page. Within the modal, there ...

Share the name of the Quasar component with the Vue 3 render function

I'm struggling to dynamically create a Vue 3 app with different components specified by name, such as "div", "button", or Quasar's "q-btn". When I try to pass the latter to Vue's render function Vue.h, I encounter difficulties. <html> ...

AngularJS: Embedding a webpage within a <div> container

I recently came across this question in STO, but unfortunately, I couldn't find a suitable answer. Currently, I am working with Angular 1.0 and sending an AJAX request to the server to retrieve a list of URLs in the following format: My challenge no ...

Displaying information in an alert box with the use of JavaScript

Every time I attempt to display data in an alert box upon button click, I encounter an issue where the alert box fails to populate. Here is what I have tried: <head runat="server"> <title></title> <script type="text/javascript" s ...

When CSS is applied, the canvas is stretched, whereas it remains normal when `width` and `height` attributes are used

I own two canvases, one is sized using HTML attributes width and height, while the other is sized using CSS: <canvas id="canvas1" width="300" height="300" onmousedown="canvasClick(this.id);"></canvas> < ...

Troubleshooting issue with image dimensions in Angular within CKEditor content

One issue I am facing is with CKEditor, where images inserted into Rich Text Fields have their height and width attributes set in a CSS style tag. For example: <img alt="" src="https://something.cloudfront.net/something.jpg" style="height:402px; ...

Tips for ensuring consistency in the appearance of a webpage across various browsers

Is it feasible to guarantee that a website will appear identical across various desktop browsers without the need to check in different ones? I am referring only to desktops, excluding tablets and smartphones. If all divs and tables are given specific pix ...

Ways to interact with a button that toggles between states

I am working with a button that has both an enabled and disabled state. Enabled State: <button type="button" class="btt-download-csv site-toolbar-menu-button icon-download no-icon-margins ng-isolate-scope" title="Download CSV" rc-download-csv="" curren ...

Is it possible to decrease the size of a div by scrolling both vertically and horizontally?

Can a div's height and width both be reduced at the same time while scrolling down a page? Let's say that as the user scrolls, the size of the div changes from 400px by 400px to 200px by 200px, all while remaining centered on the page. I've ...

What are the steps to address a bug in Bootstrap carousel?

The final element of the slider isn't displaying correctly and causing issues with the entire carousel. Strangely, if I remove the third item from the carousel, it looks good even though the last item is missing. How can this bug be resolved? Bootstra ...