Ensure that the div stays anchored to the bottom of the page while maintaining its

Although I know this question has probably been asked and answered before, I couldn't find any useful solutions to my specific problem...

I'm attempting to position a chat box div at the bottom of a page without being fixed, while still maintaining responsiveness.

In the provided example Here, the chat box is currently aligned next to another div - I would prefer to have some space between them and have the chat box open upwards instead of downwards...

The following images offer a clearer explanation:

Desired layout :

https://i.sstatic.net/3vTIJ.png

Desired layout when chat window is open:

https://i.sstatic.net/tpVOD.png

Current layout :

https://i.sstatic.net/lkw95.png

Answer №1

Could this be the solution you have been searching for? Take a look at this, it might just be the Solution to your code.

I have made some enhancements to your .faq_chat class with some additional styling.

.faq_chat{
    padding: 30px 30px 30px 30px;
    width: 66.66666667%;
    background-color: #d2f1f0 ;
    z-index: 99;
    position: fixed;//my style
    right: 0;//my style
    bottom: 0;//my style
}

Check out this Fiddle

Answer №2

#container{
    position: absolute;
    bottom: 0px;
    width: 80%;
}

Answer №3

The reason for this issue is due to the css implementation

.faq_cont_left {
    background-color: gray;
    float: left;
    width: 33.3333333%;
    height: 800px;
}

In the above css, the height given is 800px which is significantly higher than the following block css

.faq_cont_right {
    float: right;
    padding: 0;
    width: 66.66666667%;
    height: 200px;
    background-color: blue;
}

The height in this css is set to 200px. To resolve this, you can consider the following options:

  • Decrease the height of .faq_cont_left to 200px
  • or increase the height of .faq_cont_right to 800px

I hope this solution helps address your concerns.

Answer №4

Discover the power of flex for creating dynamic layouts.

To learn more about Flex, check out: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

html, body {
  min-height:100%;
  height:100%;
}

body {
  display:flex;
  flex-direction:column;
  margin:6px;
  background:red;
}

.my-app { /** Alternatively, use "body" for your app container **/
  height:100%;
  display:flex;
  flex-direction:column;
  background:#f5f5f5;
}

.header {
  background:lightgreen;
  height:80px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#fff;
}

.somecontent {
  background:tomato;
  padding:20px 0;
  margin:10px 0;
  color:#fff;
}

.chat {
  background:lightblue;
  margin:auto 0 5px 0;
  padding:10px;
}
<div class="my-app">
  <div class="header">
    My app name
  </div>
  <div class="somecontent">
    Some content...
  </div>
  <div class="chat">
    My beautiful chat
  </div>
</div>

Answer №5

The reason for this issue is related to the positioning of the element. To resolve it, you should set a fixed position for your div at the bottom.

position:fixed

I have made the necessary updates to your code example, please review it.

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

Using a single AJAX function to write on various tags

Information regarding the likes and dislikes count is retrieved from the server using an ajax function with the following queries: $q3="select count(value) as a from rank where personID='$person' and itemID='$itemID' and value>0 ...

Exploring the differences between the meta viewport and font size

My website includes the following code in the section: <meta name="viewport" content="width=990"/> This setting helps to display my webpage well on mobile devices, as using width=device-width causes issues with elements that have 100% width. Howeve ...

Is it possible to utilize the ternary operator to handle classnames when working with CSS modules?

I am experiencing difficulty implementing a styling feature using the ternary operator within an element's className. My goal is to have three buttons that render a specific component when clicked. Additionally, I want to change the background color ...

Minimize the empty space at the top of the website

Looking to eliminate the extra space at the top of this particular website. After attempting to use firebug, I still can't pinpoint the source of this unwanted spacing. Your guidance would be greatly appreciated. Thank you! ...

Swapping out DIVs with jQuery

Currently, I am working on a project for a client where I need to create a sortable biography section using jQuery. Initially, I had a setup with just two bios (first person and third person) which was functioning perfectly: $("a#first").click(function() ...

My CSS seems to be causing an issue and preventing the function from running correctly. Now I just need to

I'm currently working on a project and following a tutorial to help me create a navigation bar. The tutorial I am using can be found here: https://www.youtube.com/watch?v=gXkqy0b4M5g. So far, I have only reached the 22:05 mark in the video. I have su ...

The carousel's slides don't behave properly when swiping or using the slider controls (next/prev)

I have recently completed the construction of a carousel with swipe/touch functionality and control buttons for previous and next slides. However, I am facing an issue with the behavior of the carousel as it seems to be sliding by 2 or 3 instead of one at ...

The current layout of the div is hindering the ability to switch from vertical scrolling to horizontal scrolling

I'm currently utilizing this scroll converter tool to transform vertical scrolling into horizontal scrolling. However, despite correct script inclusion and initialization, the conversion is not working as expected. It seems like there might be an issu ...

The onclick event seems to be malfunctioning on the website

My goal is to implement a modal box that appears when a user clicks a button and closes when the user interacts with a close button within the modal box. I have created two functions for this purpose: check() : This function changes the CSS of an element ...

Is there a way to disable a JavaScript hover effect when the mouse moves away?

I came across this JavaScript code that swaps the background of a parent div when clicking on a link in a child div. However, I noticed that the hover state remains even after moving the mouse out of the link. Can someone help me modify the code so that ...

Struggling to float <aside> to the left of <article> for proper alignment?

tldr; I'm attempting to position the aside-section to the left of the article-section (similar to a sidebar/side column), but my "float" property doesn't seem to be working at all. Is there a way to achieve this without modifying the HTML code an ...

Detecting coordinates (x, y) on a canvas

I'm currently working on a mini-game and encountering an issue with the player movement around the green square. My character seems to be unable to move past the x, y coordinates of the square, even though it can approach it closely. I would really ap ...

Using Bootstrap 4 causes text to wrap buttons onto a separate line

I am facing an issue with my HTML page that displays correctly on medium and large devices but encounters difficulties on smaller screens. When the screen size decreases, the text inside the grey elements takes up all the space, causing the two right-float ...

Tips for maintaining an active link using CSS

I am looking to create a hover effect for links that remains active when the user is on a specific page. Essentially, I want a background to appear behind the link when it is visited. Below is the HTML code: <div class="menudiv"> <div id="menu"& ...

The issue arises when attempting to use Bootstrap date and time components simultaneously

I am encountering an issue with the date picker and datetimepicker when used together in my form. If I only work on time or date individually, they function properly. However, when both are included, the time is not working correctly as it displays the dat ...

jQuery toggle buttons to show or hide on radio button selection

I have a pair of buttons and a pair of radio buttons Buttons 1) btnErp 2) btngoogle Radio Buttons 1) rdiogoogle 2) rdioErp When I select 'rdiogoogle', 'btngoogle' should be visible while 'btnErp' should be hidden. Conve ...

Can Jquery be utilized to signal a language change?

I'm working on my portfolio website that will be available in two languages, Thai and English. I have successfully implemented language buttons for changing between the two languages. However, I am facing an issue with the language selection when nav ...

How can I use JavaScript to show a div upon clicking an input element?

I am looking to make a block div visible when an input field is clicked. <input class="indifferent" type="radio" name="decision" value="indifferent"> Indifferent </br> <div class="input" style="display: none;"> Please assist with our com ...

Generating HTML table rows dynamically in Angular based on the number of items stored in a $scope variable

In my current project, I am utilizing Angular to dynamically populate data in an HTML table. Instead of manually coding each row for display, I am in need of a solution that allows me to programmatically define each HTML row. The Angular controller snippet ...

Utilize Pseudo Elements for Designing a Unique Background Overlay

I am aiming to create a div with a customizable background, and then utilize a pseudo element to generate a semi-transparent white overlay that will lighten the background of the div. The crucial requirement is for the "overlay" to appear beneath the conte ...