html - 如果单词内容增加,如何到达p标签的下一行

标签 html css

如果文字内容超出屏幕,我希望段落元素的文字内容到达下一行。如何使用 css 样式实现此目的?

这是我尝试过的

template.html

  <div class="rightDiv">
   <input id="inputCustomer">
   <p id="spandiv" [ngStyle]="{'position':'absolute','left':'60px'}" >{{customerName}}</p>
  </div>

template.css

.rightDiv {
 position: relative;
 right: 320px;
 height: 80px;
 width: 160px;
}

#spandiv {
  top: 40px;
  background-color: #6B6664;
  padding: 5px;
  color:white;
  font-weight: normal;
  display: block;
  opacity:0;
  overflow: hidden;
  width: auto;
  word-wrap: break-word!important; // this is not working

}


 #inputCustomer:hover + #spandiv {
  display: block;
  opacity:1;
}  

最佳答案

您可以尝试像这样更改 th css #spandiv 中的空白:

    #spandiv {
      top: 40px;
      background-color: #6B6664;
      padding: 5px;
      color:white;
      font-weight: normal;
      display: block;
      opacity:0;
      overflow: hidden;
      width: auto;
      word-wrap: break-all;
      white-space: normal;
    }

关于html - 如果单词内容增加,如何到达p标签的下一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59263944/

相关文章:

css - 3x3 CSS 网格 : how to make center div the only one with a fixed height/width?

html - IE 7 & 8 中的 URL 参数双重编码问题

html - 奇怪而行出现在 html 中

html - html邮件中的位置相对/绝对问题

javascript - 内容溢出到 div 之外

javascript - 如果我没有分页会发生什么?只是继续循环发布...为什么需要分页,用于页脚?

html - 返回 Haskell 中字符串的第一行

html - 纯 CSS 中基于复选框隐藏表格行

javascript - 代码未在 IE 11 中运行,但在 Chrome 中运行良好

html - 在纯 CSS 中使用内联 SVG 而不是超赞的 webfont