Struggling to Ensure Chat Box Responsiveness on Mobile Devices

Currently, I'm facing a challenge with ensuring the responsiveness of a chat box UI for smaller screens. The aim is to make the chat section adaptive so that users can access all elements without having to horizontally scroll, even on small screens.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha512-MV7K8+y+gLIBoVD59lQIYicR65iaqukzvf/nwasF0nqhPay5w/9lJmVM2hMDcnK1OnMGCdVK+iQrJ7lzPJQd1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css">
    <title>Chat Box</title>
</head>

... (CSS code omitted for brevity)

<body>
    <div class="mncht">
        <section class="msger">
            ... (HTML code omitted for brevity)
        </section>
    </div>

    
    <script>
    ... (JS script snippet goes here)
    </script>


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

Despite incorporating media queries in CSS to adjust the layout based on screen size, achieving the desired level of responsiveness remains a challenge.

@media (max-width: 768px) {
    .msger {
      margin: 0 auto;
    }
  
    .msger-chat {
      max-height: 250px;
    }
}
  
@media (max-width: 480px) {
    .msger-header,
    .msger-inputarea {
      padding: 10px;
    }
}

Your assistance and insights are greatly appreciated! :)

Answer №1

It seems that the padding in ".msger-inputarea" is causing some issues for you. Try setting it to 0 in ".msger-inputarea *" when the width is smaller than 500px. Then, adjust the padding in ".msger-inputarea" to 0 for width smaller than 400px. Lastly, make sure to modify the sizes of elements such as font sizes and input field size accordingly.

Answer №2

The size of the two buttons and textarea is too large for a small screen, resulting in horizontal scrolling. To remedy this issue, consider adjusting the layout of these elements. A media query has been established to address screen sizes above 290px without altering the bottom element layout. Simply add the following code snippet at the end of your CSS file:

@media (max-width: 420px) {
  .msger {
    margin:  25px 0;
  }
  .msg-bubble {
    font-size: 0.8rem;
  }
  
  .msger-input {
    padding: 0 20px;
    width: 130px;
    
  }
  .snd-btn {
    padding: 11px 0px;
  }
}

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

Customizing Material UI Select for background and focus colors

I am looking to customize the appearance of the select component by changing the background color to "grey", as well as adjusting the label and border colors from blue to a different color when clicking on the select box. Can anyone assist me with this? B ...

How can I create text in Three.js that passes through an object?

Subject: I am trying to achieve the effect of perspective 3D text passing through another object in the scene. The background of the text should be transparent. https://i.sstatic.net/1m0Ca.jpg Bonus question: How can I animate the text like a ticker? I ...

Merge the JSON data with the Node.js/Express.js response

Whenever I input somedomain.com/some_api_url?_var1=1 in a browser, the response that I receive is {"1":"descriptive string"}. In this JSON response, the index 1 can vary from 1 to n, and the "descriptive string" summarizes what the index represents. I am ...

What makes node.js operate in an asynchronous manner?

After reviewing various 'suggestions' and conducting research, one question remains unanswered: Why does node.js operate asynchronously? Based on my findings: Languages like PHP and Python are considered scripting languages (although there may ...

Unable to assign a value to a variable within a Mongoose callback function

I am struggling to comprehend why the variable "productsAvailable" still shows true even after being set to false. router.post('/api/transactions', (req, res) => { var productsAvailable = true for(var i=0; i<3; i++) { Prod ...

The conversion function from string to integer is malfunctioning

I am currently working on a website where my client has the ability to modify their table_id. However, whenever I attempt to make these changes, the value in the database resets to 0. The table_id column is an integer type in MySQL, and I believe that&apos ...

Upon refreshing, the user of the React JS application is redirected to a different page

My React JS app utilizes react-router-dom v6 to manage the routes. Everything was working fine until I integrated Firebase Firestore. Now, when I reload the seeker page, it redirects me to the home page instead of staying on the seeker page. This issue is ...

What steps do I need to take in order to make the navbar-collapse function properly with an animated

After successfully implementing a collapsible navbar with a hamburger icon for mobile view, I decided to add some extra styling and animation to the hamburger button. However, now the hamburger button remains visible even in desktop view, which is not what ...

Is it feasible to utilize Lingua within a JS/JSON Object?

I am curious about incorporating the node.js module 'lingua' into a jQuery script like this: $('#promoText').textareaCount({ maxCharacterSize: 500, warningNumber: 40, displayFormat : "#input/#max | #words #{ lingua.words }" ...

What is the best way to include generic HTML content in an Angular 2 component?

I am looking to design a versatile modal component that can accommodate various elements, ranging from text to images and buttons. If I were to implement something like the following: <div class="Modal"> <div class="header"></div> ...

The curious case of unusual behavior in jQuery's livequery() method

When attempting to use the jQuery plugin "livequery" to highlight certain words within dynamically generated search results, the highlighting does not appear to work! Strangely, adding an alert() function before executing the code causes the highlighting ...

Updating React Native using setState is not possible

In my React Native application, there is a function that deletes an item: delete(index){ this.setState({deletedIndex:index, cachedCart:this.state.Cart, Cart: this.state.Cart.splice(index,1) }, function(){ console.log(th ...

Best practices for structuring models in a node.js web application

I've recently started delving into building a website with node.js, and I'm facing a challenge when it comes to organizing the models for my project. All the examples I've come across online use Mongoose. This library allows you to define y ...

Harvesting data from an HTML document using BeautifulSoup and Python

I am currently working on extracting text from an HTML file. The HTML file has the following structure: <li class="toclevel-1 tocsection-1"> <a href="#Baden-Württemberg"><span class="tocnumber">1</span> <span class= ...

What are the steps to creating a screen that mimics a mirror in the physical world?

Is there a way for the user to see themselves when they open a URL? I'm not looking for a mirror effect like the one produced by jQuery reflection js. I don't want to rely on using the front camera or any other camera to achieve this. Any sugges ...

Employ a class function within router.get

I'm a beginner with node.js and I'm running into an issue when trying to use a class method in the router.get callback function. Can someone assist me with this problem? Route.get() is expecting a callback function but received a [object object] ...

Running AngularJS controllers should only occur once the initialization process has been fully completed

I am facing a situation where I need to load some essential global data before any controller is triggered in my AngularJS application. This essentially means resolving dependencies on a global level within AngularJS. As an example, let's consider a ...

Configuration object for Webpack is not valid

I encountered an error while using webpack that says: Invalid configuration object. Webpack has been initialized with a configuration object that does not conform to the API schema. - configuration.resolve has an unknown property 'extension&ap ...

Align a single <td> element in the center of a row while the other row contains multiple <td> elements

I am facing an issue with centering a <td> element in a row, especially when there are multiple <td> elements in the same row. The first row's <td> element remains fixed in the first column position and does not move to the center as ...

Prompt Angular to deliberately reevaluate the DOM

Is there a method to prompt Angular to reassess the DOM? I am searching for a way to manually trigger Angular to reassess the entire DOM, or even more specifically, a certain ng-controller DOM element. Is it possible to achieve this? ...