hugo-book icon indicating copy to clipboard operation
hugo-book copied to clipboard

line break in tooltip

Open ghost opened this issue 2 years ago • 3 comments

I have a problem of using &#13; or <br>. Any idea?

I have this sentence with tooltip:

<span class = "hovertip" data-hover = "test first line &#13; second line <br> third line">Samples were hydrolyzed with sulfuric acid in methanol</span>.

my css is added to _custom.css as follows:

.hovertip {
  position: relative;
  border-bottom: 1px dotted black;
}

.hovertip:before {
  content: attr(data-hover);
  visibility: hidden;

  width: 250px;
  background-color: #add8e6;
  color: black;
  text-align: left;
  border-radius: 5px;
  padding: 5px 0;
  /* fade-in*/
  opacity: 0;  
  transition: opacity 1s ease-in-out;

  /* top tooltip*/
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 110%;
  margin-left: -60px;
}

.hovertip.hovertiptext::before {
  content: " ";
  position: absolute;
  top: 100%; /* At the bottom of the tooltip */
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: black transparent transparent transparent;
}

.hovertip:hover:before {
  opacity: 1;
  visibility: visible;
}

ghost avatar Jul 27 '22 16:07 ghost

Hi! Can you please elaborate on what you expect and get?

alex-shpak avatar Jul 28 '22 15:07 alex-shpak

I expected

test first line 
second line 
third line

I got:

test first line second line third line

ghost avatar Jul 28 '22 18:07 ghost

this is not really related to hugo-book, but a general CSS "Problem".

But let me stackoverflow that for you: https://stackoverflow.com/questions/16451553/css-data-attribute-new-line-character-pseudo-element-content-value

salzig avatar Aug 24 '22 08:08 salzig