Struggling to adjust the width of a div using CSS

Whenever I test this code on JSFiddle, everything runs smoothly. However, in Safari, it seems to be glitchy. I can't quite figure out what the issue is as the code appears to be pretty standard. The main problem lies in the chat box where the right side extends too far beyond its boundaries.

Here's a screenshot of the problem: https://i.sstatic.net/J6yxw.jpg

http://jsfiddle.net/XC4cg/

<body>
    <div class="chat">
        <input type="text" class="chat-name" placeholder="Enter your name">
        <div class="chat-messages">
            <div class="chat-message">
                Alex: Hello there
            </div>
            <div class="chat-message">
                Billy: Hello!
            </div>

        </div>
        <textarea placeholder="Type your message"></textarea>
        <div class="chat-status">Status: <span>Idle</span></div>
    </div>
</body>

CSS:

body,
textarea,
input {
    font: 13px "Trebuchet MS", sans-serif;
}

.chat {
    max-width: 300px;
}

.chat-messages,
.chat textarea,
.chat-name {
    border: 1px solid #bbb;
}

.chat-messages {
    width: 100%;
    height: 300px;
    overflow-y: scroll;
    padding: 10px;
}

chat-message {
    margin-bottom: 10px;
}

.chat-name{
    width: 100%;
    padding: 10px;
    border-bottom: 0;
    margin: 0;
}

.chat textarea {
    width: 100%;
    padding: 10px;
    margin: 0;
    border-top:0;
    max-width: 100%;
}

.chat-status{
    color: #bbb;
}

.chat textarea,
.chat-name {
    outline:none;
}

Answer №1

My laptop doesn't have Safari, so I'm thinking the problem might be related to a box-sizing issue.

Try adding this code:

.message-container {
    width: 100%;
    height: 300px;
    overflow-y: scroll;
    padding: 10px; 
    box-sizing: border-box;  
}

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

In the realm of HTML Canvas, polygons intricately intertwine with one another

Currently, I am attempting to create multiple polygons from a large JSON file. Instead of being separate, the polygons seem to be connected in some way. https://i.sstatic.net/Ce216.png The project is being developed in next.js. Below are the relevant co ...

CSS tip: Display only the latest x entries on a list

Can CSS be used to display only the most recent x items in a list? The code below reveals every item except the first two. How can I make it so that only the last two items are displayed in the list? ul li { display: none !important; } ul li:nth-las ...

Conceal the Slider until Fully Loaded with Slick Slider by Ken Wheeler

I am currently using a slider function called Slick by Ken Wheeler. It is currently being loaded in the footer with just two variables. $('.slickSlider').slick({ dots: true, fade: true }); Currently, ...

Is there a way to restrict the number of checkboxes selected based on the values of radio buttons?

I am currently working with a group of radio buttons: <input type="radio" name="attending_days" value="06-18-13"/>Tuesday June 18, 2013 <input type="radio" name="attending_days" value="06-18-13"/>Wednesday June 19, 2013 <input type="radio" ...

I came across a small piece of CSS code that isn't functioning properly when tested on jsfiddle

I'm on the hunt for a cool "typing animation" with three dots. Stumbled upon this gem online -> https://codepen.io/mattonit/pen/vLoddq The issue is, it doesn't seem to work for me. I even tried it on jsfiddle and it just stops working. I att ...

Unable to save the ID of an element into a jQuery variable

I am currently working on a project that involves an unordered list with anchor tags within it. I am trying to access the id of the li element that is being hovered over, but for some reason, the alert is returning undefined or nothing at all. Here is the ...

Utilizing HTML Canvas: Incorporating a background image along with base64 data for enhanced visual effect

I am currently working on some JavaScript tasks in Laserfiche forms where I need to save the base64 data of an image in a separate text area. This data is then fed back into the image to convert the canvas into an image that can be saved in the system. On ...

Challenges in Converting HTML String into a jQuery Object and Navigating It

I have created a small script that takes an autoresponder code from a textarea for email marketing. When the textarea loses focus, it should parse the pasted code, extract certain attributes and elements, and place them in separate input fields. However, ...

Error message indicating the inability to parse a JSON string into a DateTime object of type org.joda.time.DateTime

Produce.java(Entity class) @Column(name="productionStartFrom") private DateTime productionStartFrom; @Column(name="lastDateForBid") private DateTime lastDateForBid; @Column(name="produceDate") private DateTime produceDate; html code <div class="col ...

Looking to extract a particular set of information from past records in a GAS web application

Regarding a previous query I made before (Check for login username and password, and then bring data from every previous entry). I've developed a web application to monitor the working hours of employees at my organization. The app is straightforward ...

Whenever I include "border:0" in the styling of my hr element, a significant number of hr elements fail to appear on the screen

I have been experimenting with using hr elements to divide sections of my web page. Here is a snippet of the CSS code I am using: hr{ content: " "; display: block; height: .1px; width: 95%; margin:15px; background-color: #dfdfdf; ...

Create a grid layout with Angular Material by utilizing the *ngFor directive

I've encountered a situation where I need to manually insert each column in my component data. However, I would prefer to dynamically generate them similar to the example provided at the bottom of the page. <div> <table mat-table [dataSour ...

Creating a wavy or zigzag border for the <nav id="top"> element in OpenCart version 2.3

I'm trying to achieve a wavy/zigzag border on the <nav id="top"> section in opencart v2.3 instead of a flat border. something similar to this example Below is the CSS code I am currently using: #top { background-color: #EEEEEE; borde ...

Disappearing div: Using Angular 7 to hide a div element after a short

Having some trouble grasping how to handle this issue... There's a scroll animation on my page, and I'd like to smoothly hide the div after 3 seconds when it appears. The HTML code for the animated element is: <div class="scroll-animatio ...

Displaying the outcome of an HTML form submission on the current page

Within the navigation bar, I have included the following form code: <form id="form"> <p> <label for="textarea"></label> <textarea name="textarea" id="textarea" cols="100" rows="5"> ...

Steps to showcase a HTML modal based on the outcome of a JavaScript/AJAX database query

Currently in the process of developing a Facebook game utilizing html and Javascript. With two modals on an html page (referred to as ModalA and ModalB), the goal is to link both modals to a single button, triggering the display of only one modal based on ...

Pause jQuery at the conclusion and head back to the beginning

As a beginner in the world of jQuery, I am eager to create a slider for my website. My goal is to design a slideshow that can loop infinitely with simplicity. Should I manually count the number of <li> elements or images, calculate their width, and ...

Text with a fading black overlay

I am seeking to develop a unique transparent overlay effect for a div that includes text. The objective is to have the overlay fade in and out upon activation by pressing a button. Traditionally, this can be achieved by placing a div within another div wit ...

Adjusting the position of the floating image on the left side will impact the height of the container

When attempting to execute the code below: ​<div id="container"> //This is a 200x200 image <img src="http://dummyimage.com/200x200/CCC/000" /> </div>​​​​​​​​​​​​​​​​​​​​​​ ...

Is it possible to assign the string variable to "</a>" in PHP without it being interpreted as a command?

I am currently working on a simple web page project, where I want to include a clickable link using HTML. While I have figured out the initial steps, I'm facing an issue with the following code snippet: $URLString = "<"; $URLString .= "/a"; $URLS ...