What can I do to ensure that this is responsive across all devices?

Hey there! I need some assistance with making my Chat site/application responsive. I'm not too familiar with CSS, but I'm the sole developer on this project, so I'm trying my best. I initially designed the site in Photoshop and then started creating it using HTML & CSS. While it looks great overall, some parts are not responsive, especially the messages container. Can someone guide me on how to make everything responsive or just help me out by providing a version of the site that is fully responsive?

Here's what I have so far in terms of code:
HTML (with EJS):

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Home - <%= name %></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="/global.css">
        <link rel="stylesheet" href="/index.css">
    </head>
    <body>
        <div class="content">
            <div class="nav">
                <h1 class="navTitle">Atlas Chat</h1>
                <h2 class="navUsername"><%= user ? user.username : "Not logged in" %></h2>
                <% if(user !== null) { %>
                <a class="navitem logoutbtn" href="/logout">Logout</a>
                <% } else { %>
                <a class="navitem loginbtn" href="/login">Login</a>
                <a class="navitem" href="/register">Register</a>
                <% } %>
            </div>
            <div class="main">
                <div class="roomInfo">
                    <span class="hashtag">#</span><input type="text" class="roomname" pattern="^[a-z0-9\-]{0,16}$" required placeholder="channel-name"><button class="roomnamebtn">Join</button>
                </div>
                <hr>
             
                ... 
                
               </div>
            </div>
            <div class="users">
                <h1 class="usersTitle">Online Users</h1>
                <ul class="usersList">
                   
                   ... 

                </ul>
            </div>
        </div>
    </body>
</html>

CSS:

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

...

     

Answer №1

Responsive design is all about adaptability to different screen sizes and shapes. For instance, a layout designed for mobile devices would appear out of place on a desktop, and vice versa.

Some time ago, I created a mockup for a chat application. If you don't mind, I'd like to use it as an illustration since the code is already available online for reference.

Check it out here

When viewed on a mobile device, the app looks like this:

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

This layout is optimized for easy viewing on smaller screens with accessible chat functionality and menu options. However, when accessed from a desktop, I implemented specific CSS changes to enhance the user experience for larger screens:

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

The content is structured within a long div, simulating multiple screens that users can scroll through seamlessly by selecting different sections.

#screens{
    width: 100%; height: 100%;
    background: #2a2a2a;
    overflow: hidden;
}
#screens #viewport{
    width: calc(100% * 4); height: 100%;
    overflow: none;
}
#screens #viewport > *{
    width: calc(100% / 4); height: 100%;
    float: left;
}

For desktop users, I made adjustments to show both "rooms" and "chat" simultaneously within one screen width.

@media only screen and (min-width: 800px){
    #screens #viewport #rooms{width: 200px!important}
    #screens #viewport #chat{width: calc(100% / 4 - 200px)!important;}
}

The @media tag enables targeted styling based on screen size criteria, allowing for more customized layouts catering to various devices and orientations.

I chose this example because the CSS implementation is straightforward and comprehensible. While the code may seem lengthy, I believe it can serve as a helpful guide in creating your own responsive chat app. Feel free to ask any specific queries regarding this example.

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

Convert a NodeJS stream into a string using synchronous methods

I am aware that in NodeJS, one can read a file synchronously using the following code: var fs = require('fs'); var content = fs.readFileSync('myfilename'); console.log(content); However, I am curious about how to synchronously read th ...

Restrict the number of labels on Chart.js exclusively for smaller displays

How to Limit the Number of Labels on a Chart.js Line Chart I am looking for a way to decrease the number of labels on my line chart only when it is viewed on a small device. The solution provided in the previous post suggests using the following code: xAx ...

Increasing space at the top with heading

As I scroll down, the header on my website remains in a static position and disappears. However, when I scroll back up, the header reappears wherever the user is on the page. While this functionality works well, I have noticed that as I scroll all the way ...

Active Tab Indicator - Make Your Current Tab Stand Out

I currently have a set of 3 tabs, with the first tab initially highlighted. I attempted to use some JQuery code in order to highlight a selected or active tab, but for some reason it is not working as expected. Any assistance would be greatly appreciated. ...

Incorporate text onto an image using Semantic UI

Currently, I am utilizing Semantic UI to display images. While it is functioning well for me in terms of adding text near the image, I desire to have the text positioned on top of the image. Ideally, I would like it to be located on the lower half of the i ...

Deploying a Typescript-enabled Express application on the Azure cloud platform

Currently, I am attempting to deploy an Express server on Typescript on Azure by following the guidelines provided in this tutorial: https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=windows&pivots=development-environment-vsco ...

Clickable functionality disabled for form elements

I am encountering an issue with my system development task. The form elements appear to be unclickable, preventing any data entry in the fields. I have attempted moving the form tag above the first div in the code structure below as a troubleshooting step, ...

Stylish Navigation Menu Logo/Site Name

Currently in the process of upgrading my website and I have my website name included as part of my menu, as opposed to a logo. This has been an easy solution that has worked well for me. For mobile screens, the template I purchased includes a slicknav men ...

Leveraging CSS to automatically number nested sections

Assume we have an example HTML or XML document structured like this: <body> <section> <h1>This should be numbered 1</h1> <section> <h1>This should be numbered 1.1</h1> <p>blah& ...

A guide to managing entity data in Google Datastore with Node.js

I am facing issues when it comes to setting and retrieving entity data from the Google Datastore. The various examples I have come across are confusing me, and I'm unsure which one is correct. Below is a snippet of the code I have been working on, but ...

How can I create a dashed border for a pie chart using highcharts?

Is there a way to change the default solid border of a pie highchart to dashed? This modification is only necessary for pies without data or with negative data values. Perhaps it's possible to redraw the SVG of the border, like in this example: https: ...

Monitor the download status of clients from the server

My current situation involves numerous Linux-based clients that are downloading firmware updates from my webserver. Once the client has completed the download of the firmware file, my server is required to run a series of scripts. These scripts will log i ...

The behavior of CSS classes, unique characters, and the usage of class prefixes

I'm dealing with a template that contains some puzzling CSS selectors. The syntax in question is as follows: .\35 grid .\31 1u { width: 91.5%; }, but the '\' character appears as a strange symbol in Notepad++. Can someone ex ...

Is there a way to modify the style value within AngularJS?

<div class="meter"> <span style="width: 13%"></span> </div> I have the following HTML code snippet. I am looking to update the width value using AngularJS. Does anyone have a solution for this issue? ...

Trouble with the div element's change event

Hey there! I'm having trouble with this jQuery code that is supposed to fade in or fade out a div based on its contents. Here is the HTML code: <div class="mainContentWrapper"> sample text </div> And here is the CSS code: div.main ...

The iPhone is having trouble resizing background images in Bootstrap 5 Carousel

While working on my website using the Bootstrap 5 carousel template, I encountered an issue with the carousel images not resizing correctly on my iPhone. The images appear zoomed in to the upper left corner and cut off on smaller devices. I've attemp ...

Customizing HTML forms using WordPress Divi's custom CSS techniques

I have a WordPress website that I'm customizing with the Divi theme. I've successfully added an HTML form to a 'Code' module and it's functioning well. However, I am struggling to determine where I should place the CSS code. I&apos ...

Element with absolute positioning and full width extends past its containing element

I'm trying to achieve a display: flex with position: fixed that has the same width as its parent. However, my current code is extending beyond the boundaries of the parent container. Here's what I've attempted so far. Please review the fidd ...

Is it possible to achieve this shaded gradient effect using CSS3?

Check out this image for reference. I've managed to style a horizontal rule using SVG as the background image, creating a specific effect. However, I am struggling to achieve the same result using CSS3 alone. If there are any CSS experts who can adv ...

Error encountered with Paypal code. Being redirected to error code 400

Hello everyone, I am currently working on creating a simple webpage and practicing how to integrate PayPal into our website. However, I seem to be encountering an issue where it is redirecting me to a 400 error page. Below is the code snippet that I have ...