html - Showing truncated text on hover using CSS ellipsis overlaps text below it -


i have name tag in sidebar should display single line , truncate if long text follow triple dots (lorem ipsum...) , should show full text on hover.

i able achieve using css problem when full text displayed overlaps text below it. (images attached)

html

<p class="name">     lorem ipsum lorem ipsum lorem ipsum </p> 

css

.name{     color: #0079c1;     height: 2em;      line-height: 1em;      font-size: 20px;     font-weight: 400;     text-overflow: ellipsis;     margin-bottom: 12px;     cursor: pointer;     word-break: break-all;     overflow:hidden;     white-space: nowrap; }  .name:hover{     overflow: visible;      white-space: normal;  } 

here jsfiddle

text overlapping on hover. expected behaviour should push content below it. enter image description here

you can add height:auto hover state , it'll work fine:

js fiddle

.name{      width:120px;      color: #0079c1;      height: 2em;       line-height: 1em;       font-size: 20px;      font-weight: 400;      text-overflow: ellipsis;      margin-bottom: 12px;      cursor: pointer;      word-break: break-all;      overflow:hidden;      white-space: nowrap;  }  .name:hover{      overflow: visible;       white-space: normal;      height:auto;  /* added line */  }
<p class="name">  lorem ipsum lorem ipsum lorem ipsum ipsum lorem ipsum  </p>  <span>    lorem ipsum dolor sit amet, consectetur adipisicing elit. quidem voluptate deserunt consequatur velit, alias ullam fuga aspernatur, ut doloremque eos fugiat quo accusamus minus distinctio quasi, recusandae excepturi molestiae.  </span>


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -