The information overflow occurs outside the tooltip specifically in Chrome, while functioning perfectly in IE11

As a newcomer to the CSS world, I am experimenting with adding a block-level element (div) inside an anchor tag's :hover pseudo-class popup. The div element contains a table that needs to have dynamic sizing for both the table itself and its cells (with minimum and maximum width parameters). While I've managed to create a snippet that works correctly in IE11, I'm facing issues with text wrapping in Chrome. I've tried various options like overflow wrap, word-wrap, word break with break-word and break-all settings, but they only seem to work in IE11, not in Chrome.

Expectation: Content should be wrapped correctly in all browsers, but it's currently only working as expected in IE11

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

.header {
  color: #1aa3ff;
  //width: 30%;
  border: 1px solid #cccccc;
  min-width: 50px;
}

.value {
  //width: 70%;
  border: 1px solid #cccccc;
  padding: 5px;
  min-width: 100px;
  max-width: 250px;
  word-break: break-all;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre;
}

a.System {
  position: relative;
  display: inline;
}

a.System .tooltiptext {
  position: absolute;
  width: auto;
  display: inline-block;
  color: red;
  background: #737373;
  border: 2px solid #000000;
  text-align: left;
  visibility: hidden;
  border-radius: 6px;
  z-index: 1;
  //left: 80%;
  margin-left: auto;
  //padding: 5px;
  top: 50%;
  transform: translateY(-50%);
}

a.System .tooltiptext:before {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -12px;
  width: 0;
  height: 0;
  border-right: 12px solid #000000;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
}

a.System .tooltiptext:after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid #737373;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.System:hover .tooltiptext {
  visibility: visible;
}
<h2>Right Tooltip w/ Left Arrow</h2>

<a class="System">Hover over me
  <div class="tooltiptext">
  <table>
    <tr>
      <td class="header">Name</td>
      <td class="value">Sar</td>
    </tr>
    <tr>
      <td class="header">Group</td>
      <td class="value">Group Name1 <br>Group Name 2 Group Name 2 Group Name 2</td>
    </tr>
  </table>
  </div>
</a>

Answer №1

https://i.sstatic.net/TN9Lc.png@Saravanan, your code snippet provides a solution to the question at hand. I have made some modifications by replacing // with /* */ for proper CSS commenting and commented out unnecessary CSS properties in the .value section as shown below. This adjustment ensures compatibility with both IE11 and Chrome.


word-break: break-all;
overflow-wrap: break-word;
word-wrap: break-word;
white-space: pre; 

.header {
  color: #1aa3ff;
/*   //width: 30%; */
  border: 1px solid #cccccc;
/*   //min-width: 50px; */
}
a{
  display: block;
}
.value {
/*   //width: 70%; */
  border: 1px solid #cccccc;
  padding: 5px;
  min-width: 100px;
  max-width: 250px;
/*   word-break: break-all;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: pre; */
}

a.System {
  position: relative;
  display: block;
}

a.System .tooltiptext {
  position: absolute;
  width: auto;
  display: inline-block;
  color: red;
  background: #737373;
  border: 2px solid #000000;
  text-align: left;
  visibility: hidden;
  border-radius: 6px;
  z-index: 1;
/*   //left: 80%; */
  margin-left: auto;
/*   //padding: 5px; */
  top: 50%;
  transform: translateY(-50%);
}

a.System .tooltiptext:before {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -12px;
  width: 0;
  height: 0;
  border-right: 12px solid #000000;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
}

a.System .tooltiptext:after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid #737373;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.System:hover .tooltiptext {
  visibility: visible;
}
<h2>Right Tooltip w/ Left Arrow</h2>

<a class="System">Hover over me
  <div class="tooltiptext">
   
  <table>
    <tr>
      <td class="header">Name</td>
      <td class="value">Sar</td>
    </tr>
    <tr>
      <td class="header">Group</td>
      <td class="value">Group Name1 <br />Group Name 2 Group Name 2 Group Name 2</td>
    </tr>
  </table>
  </div>
 </a>

Answer №2

The issue stems from the implementation of white-space: pre

pre
This rule preserves sequences of white space and only breaks lines at newline characters or <br> elements.

To resolve the problem, simply eliminate this rule.

Another concern relates to your usage of "comments". The correct syntax is /* ... */ instead of // ...
(MDN | Comments - CSS)

.header {
  /* width: 30%; */
  color: #1aa3ff;
  border: 1px solid #cccccc;
  min-width: 50px;
}

.value {
  /* width: 70%; */
  border: 1px solid #cccccc;
  padding: 5px;
  min-width: 100px;
  max-width: 250px; /* undefined behavior -> https://stackoverflow.com/questions/8465385/how-can-i-set-the-max-width-of-a-table-cell-using-percentages*/
  word-break: break-all;
  word-wrap: break-word;
}

a.System {
  position: relative;
  display: inline;
}

a.System .tooltiptext {
  position: absolute;
  width: auto;
  display: inline-block;
  color: red;
  background: #737373;
  border: 2px solid #000000;
  text-align: left;
  visibility: hidden;
  border-radius: 6px;
  z-index: 1;
  margin-left: auto;
  top: 50%;
  transform: translateY(-50%);
}

a.System .tooltiptext:before {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -12px;
  width: 0;
  height: 0;
  border-right: 12px solid #000000;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
}

a.System .tooltiptext:after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  margin-top: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid #737373;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.System:hover .tooltiptext {
  visibility: visible;
}
<h2>Right Tooltip w/ Left Arrow</h2>

<a class="System">Hover over me
  <div class="tooltiptext">
  <table>
    <tr>
      <td class="header">Name</td>
      <td class="value">Sar</td>
    </tr>
    <tr>
      <td class="header">Group</td>
      <td class="value">Group Name1 <br />Group Name 2 Group Name 2 Group Name 2</td>
    </tr>
  </table>
  </div>
</a>

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

CarouFredSel Transition Troubles

I am currently using CarouFredSel to create an image carousel, but I am encountering some issues with the transitions between items. My goal is to incorporate simple HTML elements into the carousel instead of just plain images. However, when I attempt to ...

Issues with the width of Table TD cells not being responsive

I'm having trouble adjusting the width of my dropdown menu columns. I've tried various methods, but can't seem to get each column to be 200px wide as desired. .dropbtn { background-image: url("../sliki/meni.png"); width: 220px; heig ...

Utilizing CSS3 webkit-transitions with multiple properties on a div element along with multiple webkit-transition-delays

Is there a way to make a div slide 200px to the right and then reduce its scale by half separately? I want it to slide first and then scale, but currently both transformations happen simultaneously. I tried using webkit-transition-delay to set different ...

Tips for expanding the contentedible HTML element downwards within its container

When a user inputs content, I need the paragraph to expand only downward while the div with the ID of description also grows in the same direction. The main parent div labeled documentation should remain fixed so it doesn't expand upwards. This scenar ...

Retain the jQuery dropdown menu in an open state while navigating to a different webpage on the

I am encountering an issue with a drop-down menu on my website. Whenever I click on a submenu link, the new page opens but the menu automatically closes. However, I want the active menu to remain open even on the new page. To solve this problem, I believe ...

When viewed on a mobile device, the entire HTML document is resized to occupy less than half of the

Whenever I adjust the size of my webpage on different devices or mobile phones, I notice that the <div> tag appears to be only half (or even less) the width of the page. This gap seems to increase as the window size decreases. Refer to the screenshot ...

modify the appearance of HTML controls in real time with C#

Is there a way to dynamically add an additional navigation item to my website's menu list when the admin logs in through admin.aspx? The menu list is created using HTML controls such as <ul>...<li>, and I would like the new navigation item ...

A set of six DIV's, divided into two columns of three each

I'm attempting to arrange two columns with three vertical DIVs side by side. The left column is designated for main text, while the right column is reserved for miscellaneous information. Each column consists of a top and bottom DIV that display image ...

Tips for correctly loading all elements on an HTML page before making CSS modifications

This question has been asked several times in the past. I am asking because when I used the on ready callback in jQuery, it did not change the placeholder text of my element "search_input". $( document ).ready(function() { $("#search_input").attr(' ...

Positioning an Element on a Web Page in Real-Time

Trying to implement an Emoji picker in my React application, I have two toggle buttons on the page to show the picker. I want it to appear where the Toggle button is clicked - whether at the top or bottom of the page. The challenge is to ensure that the pi ...

The <h1> element is not responding to the style attribute

Exploring HTML as a beginner has led me to an interesting issue. I've been practicing my newfound skills on W3Schools' platform and everything was running smoothly until I encountered a discrepancy in how the code is rendered on Wordpress. The s ...

The functionality of Responsive CSS seems to be inconsistent, as it only works partially

Hey everyone, I'm struggling with my responsive CSS code. It seems to be working fine with max-width: 321px but not when I try max-width: 500px. I'm trying to figure out what I'm doing wrong and would really appreciate some help. /*/Mobile ...

"Ensure that the data in the div is being updated accurately via AJAX in ASP.NET MVC

I'm currently using a div element to display data on page load through AJAX calls. $(document).ready(function () { email_update(); }); function email_update() { $.ajax({ url: '@Url.Action("EmailsList", "Questions")', ...

This webpage is optimized for all browsers, with the exception of the Android Browser that may display fonts with larger sizes

When developing my webpage, I made sure it was compatible with all major browsers and even optimized it for mobile browsers. However, I overlooked testing the page on Android browser (specifically Android 4.2) and encountered some issues. The viewport set ...

Ensuring a Fixed Delta Tooltip in lightweight-charts is essential for maintaining a seamless

I have implemented lightweight-charts to present a chart using mock data. I am looking to establish a fixed Delta Tooltip on the chart when the page loads, with predetermined start and end dates that are specified as input. Furthermore, I aim to restrict t ...

Customize the border of the Tab indicator within Material UI

I created a custom NavBar with a unique tab indicator implementation: indicator: { background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)', }, <Tabs classes={{indicator: classes.indicator}} onChange={handleClickTab} value={value}> ...

Using jQuery to store the last selected href/button in a cookie for easy retrieval

Recently, I've been working on a document that features a top navigation with 4 different links. Each time a link is clicked, a div right below it changes its size accordingly. My goal now is to implement the use of cookies to remember the last select ...

Tips on emphasizing all div elements and incorporating navigation to each of them

I am seeking a method to enhance a div with highlighting when there is a click or mouseover event. For instance, changing or adding a border color using JavaScript on click or mouseover is straightforward. Recently, I have been contemplating the idea of a ...

Fullscreen overlay or pop-up display

I have a website with images and iframes displayed within a fancybox. Everything is functioning properly, but now the website's requirement is to have a fullscreen overlay like on the usatoday website. Take a look at for reference. When clicking on ...

A collection of items displayed in an unordered format across two columns

I need help creating a list that displays in two columns. One column for odd numbers, the other for even numbers. Here's an example of what I'm trying to achieve: +----------------------------------------------------+ | col- ...