Why is the text wrapped but no hyphens are shown?
P粉060112396
P粉060112396 2023-09-14 19:55:12
0
1
526

This is the code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
  
  <ol class="meaning">
    <li class="meaning-item">这是一个示例句子,其中长单词应该被连字符分隔
      <ul class="sentences">
        <li class="sentence">这是一个示例句子,其中长单词应该被连字符分隔</li>
        <li class="translation">这是一个示例句子,其中长单词应该被连字符分隔</li>
      </ul>
    </li>
  </ol>
  
</body>
</html>

.meaning {
  list-style-type: none;
  counter-reset: item;
  font-size: calc(0.7em + 2.5vw);
  word-break: break-all;
  hyphens: auto;
}

.meaning > li {
  position: relative;
}

.meaning > li::before {
  content: counter(item);
  counter-increment: item;
  position: absolute;
  top: 0;
  text-align: center;
  margin-left: calc(-0.7em - 2.5vw);
}

.sentences {
  list-style-type: none;
  padding-left: 0;
}

The words are wrapped the way I want them to be, but the hyphen itself ("-") is not showing up where the words wrap.

Additionally, I want to explicitly tell the browser that the text in

  • is in English (en), # The text in
  • ## is in German (de). I know not all browsers have language-specific built-in directives for hyphens, but I wanted to give it a try.

    I also saved this code in JS Bin.

    Thanks!

  • P粉060112396
    P粉060112396

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!