The CSS max-width property is malfunctioning, causing line breaks to appear after reaching the

Can someone assist me with this article? I have a couple of questions: Firstly, why isn't the max-width working in the code below? Secondly, how can I make the content in the tooltip continue until it reaches the max-width and then moves to the next line? Thank you in advance.

.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    max-width:500px;
    background-color: #555;
    color: red;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}
<body style="text-align:center;">

<h2>Tooltip</h2>
<p>Move your mouse over the text below:</p>

<div class="tooltip">Hover over me
  <span class="tooltiptext">TooltiptextTooltiptextTooltiptextTooltiptextTooltiptext</span>
</div>

</body>

Answer №1

Include these 2 styles in the tooltip div

word-break: break-all;
word-wrap: break-word;

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

Preventing Safari 16 (macOS) from automatically selecting the current date in an HTML <input type="date"> field

I am encountering an issue with Safari where date fields are defaulting to today's date if no date is selected. I have tried various methods to make the field blank when no date is chosen, but so far, nothing seems to work. In all other browsers, the ...

Is there a way to retrieve values from a different menu without the need to refresh the page?

Whenever a radio button is clicked on a form, a popup menu is displayed. The popup menu is implemented using the Bootstrap module. However, there is an issue where selecting an option from the popup menu causes the form to reset, resulting in the loss of ...

AngularJS: intercepting custom 404 errors - handling responses containing URLs

Within my application, I have implemented an interceptor to handle any HTTP response errors. Here is a snippet of how it looks: var response = function(response) { if(response.config.url.indexOf('?page=') > -1) { skipException = true; ...

Avoid using <input oninput="this.value = this.value.toUpperCase()" /> as it should not convert the text displayed on the "UI", rather it should send the uppercase value

<input oninput="this.value = this.value.toUpperCase()" type="text" id="roleName" name="roleName" class="form-control width200px" [(ngModel)]="role.roleName"> Even though the UI is changing ...

PHP struggling to retrieve information from an HTML form

My PHP page is having trouble retrieving values from the HTML form. It keeps sending empty strings to the database. Below are my HTML and PHP code snippets. I am new to PHP and struggling to identify the issue. Please assist in finding the error. HTML s ...

How can I align text within an Input component to the right or center using MaterialUI?

Is there a way to align text within a Material UI input text element? The code snippet below doesn't seem to have any effect. I am currently working with version 1.x of Material UI. import {Input} from 'material-ui'; //Alignment attempt th ...

Tips for saving the text content from the "a" tag within a div into an array

I am currently working on an API that is designed to extract data from a specific website. The structure of the website looks like this - > <div id="mainContainer"> <a class="item">text1</a> <a class="item&q ...

unable to see the scroll on either end

Hey there, I could use some assistance with an issue I'm facing. The scroll bars are not showing up on either side of the page. My body has a height and width set to 100%, while the inner elements have specific dimensions that should trigger the scrol ...

What is the correct way to set the height and width for mat-select?

Can anyone help me figure out how to use flexbox to display two columns side by side? The first column should be a mat-input input box and the second one a mat-select dropdown. I want both items to have the same width with a gap between them, so I've ...

implementing lazy loading for images within styled components

const UserBackgroundImage = styled.div` background: url(${(props) => props.backgroundImage}) no-repeat center center; } In my styling component, I have utilized a div for displaying background images. However, I am facing a flickering issue while wai ...

When dragging a row with hidden fields, the thead and tbody sections in JQueryUI sortable shrink

I am working with a table that contains various rows and fields. In one row, I have two fields set to display:none;. When I drag this row, it creates a lateral padding effect in the <tbody> and the <thead>, rather than shrinking the table itsel ...

Position the div to align with just one side of the table-cell

I am struggling with making the height of my code dependent on only the left column, while still allowing the right column to be scrollable if it contains more content than the left column. Despite my best efforts, I can't seem to figure out how to a ...

Elastic video player embedded in a flexbox

I'm having an issue trying to make a responsive YouTube embed work inside a flex container alongside other content. The problem is that the container for the YouTube embed doesn't resize properly and ends up overlapping with other elements. To be ...

Concealing an element upon clicking with jQuery

Can someone help me with this issue? I'm trying to use jQuery to hide the div element with the ID 'professional-panel' when a button with the ID 'hideButton' is clicked. I know it should be simple, but I'm new to jQuery and s ...

Organize JSON array information into HTML elements

Here is an example of JSON data: {"_id":"56af2ca2eb91bd4721443037","username":"xxxxxx","userGroup":[{"groupName":"nodeJs","groupAssigned":"No","_id":"56b086ccd1bc72eb21d99c62"},{"0":{"groupName":"php","groupAssigned":"No","_id":"56b0880d13c9fc4c22a1d291"} ...

Radio button validation issue in Angular not resolving

Issue with radio button validation in Angular form. Even when a radio button is not selected, the form submits without displaying any error messages. HTML Code <form [formGroup]="feedbackFormWithArray" (ngSubmit)="submitData()"> ...

Out of nowhere, the functionality for printing labels in html/css has stopped

For over 3 years, a website has been successfully printing labels for shoes. However, the functionality suddenly broke two days ago, specifically the labels or page-break-after feature stopped working correctly. Despite searching online, I was unable to d ...

Comparing GET and POST actions in mod_rewrite search form

Hey there, thank you for taking the time to address this query. I have implemented a live search form using jQuery on my website. The search bar is present on every page and functions well. Now, I am looking to enhance its functionality. When users press ...

The form submits automatically upon loading the page with empty input fields

I recently created a form on my website located at . Initially, the form functioned correctly and the PHP script executed as expected. However, I am now encountering an issue where every time I load the page, a popup message appears indicating that the for ...

Incorporating Background Image with CSS Gradient - A Winning Combination!

Can anyone help me figure out what's wrong here? The gradient is working fine, but the image isn't showing up. You can view the page on my Wordpress site at: body { background-color: #FFF !important; /* setting a fallback color if gradi ...