Unusual alterations to HTML and CSS to meet specific needs

Struggling with bringing my website ideas to life! My header contains a navigation bar, followed by a centered chat box within a fixed <section>. Want the left and right side of the chat box to be content areas that scroll in sync while the chat box stays fixed.

Attempts at creating a content wrapper with padding and margins failed as content kept going over. Also struggled to position the left and right sections correctly.

Here is some of my HTML and CSS:

body {
    background-color: #2A0944;
    font-family: 'Roboto';
}

* {
    margin: 0;
    padding: 0;
}
i {
    margin-right: 10px;
}



.chat-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    width: 40%;
    left: 30%;
    top: 80px;
}
<header>
    <div id="navbar-animmenu">
        <ul class="show-dropdown main-navbar">
            <div class="hori-selector"><div class="left"></div><div class="right"></div></div>
            <li>
                <a href="#"><i class="fas fa-wrench"></i>&nbsp;Demo</a>
            </li>
            <li class="active">
                <a href="#"><i class="fas fa-robot"></i>&nbsp;ChatBot</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-map-pin"></i>&nbsp;About</a>
            </li>
            <li>
                <a href="#"><i class="fas fa-users"></i>&nbsp;Team</a>
            </li>
        </ul>
    </div>
</header>

<body>
   
    <section class="chat-section">


        <div class="mode-selector">
            <button class="mode-button" id="normal-mode">Normal Mode</button>
            <button class="mode-button" id="material-mode">Material Mode</button>
        </div>
    
        <div class="chatbox">

          <div class="messages-container"></div>
          
          <div>
          <div class="send-section">
            <button class="clear-chat"><i class="fas fa-poo"></i></button>
            <input type="text" class="message-input" placeholder="Talk with ChatBot ..."/>
            <button class="send-button">Send</button>
            </div>
            </div>
        </div>
      </section>

    <script src="main.js"></script>
</body>

Having no issues with CSS for items in the navigation bar and chatbox, but struggling most with adding left and right sections. Do I need to modify the current chatbox? How can I ensure scrolling keeps content below a certain line? Any advice appreciated!

Mentioned above the struggles with using a content wrapper unsuccessfully.

Answer №1

Below is a simple solution using a 3-column flexbox layout. The middle column contains a "chatbox" that has the following CSS:

width: 150px;
position: sticky;
top: 0;
height: calc(100vh - 20px);
  • The width property sets the width of the column.
  • The position: sticky and top: 0 properties keep the element fixed at the top as you scroll.
  • The height: calc (100vh - 20px) ensures that the element's height matches the window height, accounting for padding.

body{margin:0; padding:0;}
#wrapper{
display: flex;
background: purple;
color: white;
min-height: 100vh;
}

.side{
padding: 10px;
}

#chatbox{
width: 150px;
background: #CCC;
color: black;
padding: 10px;
position: sticky;
top: 0;
height: calc(100vh - 20px);
}
<main id="wrapper">
<div class="side">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas...</p>
...additional content here...
</div>
<div>
<div id="chatbox">
This is the chatbox
</div>
</div>
<div class="side">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
...more content here...
</div>
</main>

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

Ensuring consistent placement and scrollability of two divs across all screen sizes

I am in need of a solution to fix the top and bottom divs in the given image. The scroll should only occur when there is overflow. <!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> ...

Arrange TD's from various TR's underneath each other in a stack

Imagine we have a table that needs to be made responsive. <table> <tr> <td>Dog Image</td> <td>Cat Image</td> </tr> <tr> <td>Dog Text</td> <td>Cat Text</td> & ...

How can we automate the process of assigning the hash(#) in Angular?

Is it possible to automatically assign a unique hash(#) to elements inside an ngFor loop? <div *ngFor="let item of itemsArray; index as i"> <h3 #[item][i]> {{ item }} </h3> </div> I would like the outp ...

Showing an image stored in an array using JavaScript

This script is designed to pull images from a specific location on an HTML page. images = new Array(); images[0] = new Image(); images[0].src = "images/kate.jpg"; images[1] = new Image(); images[1].src = "images/mila.jpg"; document.write(images[0]); I&a ...

There seems to be a hitch in the functioning of the JavaScript codes

I'm having trouble calculating the amount using jQuery. Could someone please review my code and let me know what's wrong? Here are my Javascript and jQuery codes: After making changes: $(document).ready(function() { $('.home_banner&ap ...

Show a table with rows that display an array from a JSON object using JavaScript

My current code includes JSON data that I need to display in table rows, but I'm struggling to understand how to do so effectively. The output I am currently seeing is all the rows from the array stacked in one row instead of five separate rows as in ...

The background image in CSS fails to display on IE11 when applied to a pseudo-element with the position set to fixed

Check out the issue showcased in JSfiddle: https://jsfiddle.net/qjtbchpu/11/ <div id="container"> <article> content here </article> <article> more content here </article> </div> #container::before { ...

Display only a loading image with a see-through background after submitting the page

After submitting the page, I would like to display a loading image in the middle of the page with a transparent background. The current styling code I have used is as follows: #loading { position: fixed; top: 50%; left: 50%; z-index: 1104; ...

Steps to activate checkbox upon hyperlink visitation

Hey there, I'm having a bit of trouble with enabling my checkbox once the hyperlink has been visited. Despite clicking the link, the checkbox remains disabled. Can anyone provide some guidance on how to get this working correctly? <script src=" ...

Reduce the transparency of the overlay picture

I have been utilizing the 'Big Picture' template to design a webpage. The overlay.png file adds a lighter background effect by overlaying intro.jpg with a partially transparent blue graphic. Despite my efforts to adjust the opacity and gradient/R ...

What causes the alignment of text to be overridden by the presence of a floating element?

https://jsfiddle.net/u0Ltgh3e/68/ .text { width: 50%; text-align: justify; } I am currently developing a custom formatting tool for a specific purpose and I am attempting to create a two-column layout similar to the one demonstrated in this Jsfiddle l ...

Methods for inserting text into a WebBrowser Document without retrieving any Attributes in vb.net

Is it possible to retrieve text from a WebBrowser Document in vb.net without retrieving any attributes?! For example: <h1>text here</h1> Or: <h1 name="anything">text here</h1> How can I extract the "text here" within the <h1 ...

Seamless transition of lightbox fading in and out

Looking to create a smooth fade in and out effect for my lightbox using CSS and a bit of JavaScript. I've managed to achieve the fading in part, but now I'm wondering how to make it fade out as well. Here is the CSS code: @-webkit-keyframes Fad ...

Prevent lengthy headers from disrupting the flow of the list items

I've encountered an issue while working on a website that features a list of items. When the title, such as "roller blinds," spans across two lines, it disrupts the layout below. How can I prevent this from happening without compromising on having lon ...

Unneeded return is necessary when utilizing recursion and restarting the application

Recently, I successfully recreated the 2048 game in Java, which was a pleasant surprise to me as I didn't expect to create something this "advanced." During the game, when tiles are moved, a new square/tile/number needs to be generated. To find an av ...

Harnessing the power of external Javascript functions within an Angular 2 template

Within the component, I have a template containing 4 div tags. The goal is to use a JavaScript function named changeValue() to update the content of the first div from 1 to Yes!. Since I am new to TypeScript and Angular 2, I am unsure how to establish comm ...

Troubleshooting the issue with UI-Router AngularJS controller not functioning properly in a

Trying to grasp the ins and outs of UI-Router in conjunction with Angular has proven to be quite challenging for me. In my setup, there's an index: <body> <div ui-view></div> <!--Location of file holding app--> <scri ...

Unusual marking on the navigation bar

Currently, I am making updates to a website that was created by a previous employee long before I joined the team. One of the requested changes is to eliminate the orange box surrounding the navigation links. The navigation appears to be generated using Ja ...

The slider causing conflicts with widgets and content positioned below it in an HTML layout

When implementing a slider with a fade effect, there seems to be an issue with the placement of widgets on the homepage. The problem arises from the margin-top setting as when images change in the slider, the widgets clash with the slider. During the trans ...

Tips for successfully transferring an image through an XMLHttpRequest

I found this helpful resource at: I decided to test out the second block of code. When I made changes in the handleForm function, it looked like this: function handleForm(e) { e.preventDefault(); var data = new FormData(); f ...