0

I'm trying to implement ellipsis and it's partially working - I am having one problem, when I hover on the very long work, it goes on top of the other words. I can't explain it very well, so here's a picture to show what exactly is happening:

Before hover: Before hovering

After hover: after hovering

Here's my code:

.attachment td {
  max-width: 300px;
  overflow: hidden;
  display: inline-block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment td:hover {
  overflow: visible;
  white-space: normal;
}
<body>

  <h1>The text-overflow Property</h1>

  <p>Hover over the div below, to see the entire text.</p>

  <div class="a">This is some long text that will not fit in the box.</div>

  <table class="table table-striped table-hover">
    <tbody>
      <tr class="attachment hover-parent">
        <td>
          bhdvbcjkdsbjdhskbcsajdkggfbjaksbfisjkadzhfnisfjdkzvbcds,zhvmcneajsdkzvbdjszvbsdjzkvbdsjzkxvbdscjkvbdcxzjhvbdfshzjkxvbd
        </td>
        <td>
          download
        </td>
        <td>
          delete
        </td>
      </tr>
    </tbody>
  </table>

I feel like I'm missing out on one thing, I just can't pin point it. Any help?

Edit: Here's my desired effect: enter image description here

Edit: What I needed was overflow-wrap: breakword;, thanks Raina

Linda Kadz
  • 329
  • 2
  • 17

2 Answers2

0

overflow-y is better

https://jsfiddle.net/2g1jham6/

<head>
    <style> 
     .attachment td {
      max-width: 300px;
      overflow: hidden;
      display: inline-block;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    
     .attachment td:hover {
         overflow-x: hidden;
      overflow-y: scroll;
      white-space: pre-wrap;
    }
    </style>
    </head>
    <body>
    
    <h1>The text-overflow Property</h1>
    
    <p>Hover over the div below, to see the entire text.</p>
    
    <div class="a">This is some long text that will not fit in the box.</div>
    
    <table class="table table-striped table-hover">
              <tbody>
                <tr class="attachment hover-parent">
                  <td>
                  bhdvbcjkdsbjdhskbcsajdkggfbjaksbfisjkadzhfnisfjdkzvbcds,zhvmcneajsdkzvbdjszvbsdjzkvbdsjzkxvbdscjkvbdcxzjhvbdfshzjkxvbd
                  </td>
                  <td>
                  download
                  </td>
                  <td>
                    delete
                  </td>
                </tr>
              </tbody>
            </table>
Moti Salamon
  • 152
  • 8
0

I've updated your code. The reason for the overlapping is because you have download and delete in their own td elements in the same table.

See below

.attachment {
  max-width: 300px;
  overflow: hidden;
  display: inline-block;
  text-overflow: ellipsis;
  white-space: no-wrap;
  width: auto;
}

.attachment:hover {
  overflow: visible;
  white-space: normal;
}

.option {
display: inline-block;
text-overflow: none;
}
<body>

  <h1>The text-overflow Property</h1>

  <p>Hover over the div below, to see the entire text.</p>

  <div class="a">This is some long text that will not fit in the box.</div>

  <table class="table table-striped table-hover">
    <tbody>
      <tr>
        <td class="attachment"> bhdvbcjkdsbjdhskbcsajdkggfbjaksbfisjkadzhfnisfjdkzvbcds,zhvmcneajsdkzvbdjszvbsdjzkvbdsjzkxvbdscjkvbdcxzjhvbdfshzjkxvbd
        </td>
        <tr>
        <td class="option">
        download
        </td>
        <td class="option">
        delete
        </td>
        </tr>
      </tr>
    </tbody>
  </table>
Aib Syed
  • 3,118
  • 2
  • 19
  • 30