首页 > 解决方案 > 如何让 CSS 完全删除溢出的文本部分?

问题描述

我的 div 中有一些文本,并且希望溢出的文本完全不被 css 显示。我知道如何通过overflow: hidden;在下面的示例中使用来隐藏它,但在这种情况下,隐藏的文本仍然在页面中(例如它是可搜索的)。实际上我希望删除文本的溢出部分。

div {
  background-color: #eee;
  width: 200px;
  height: 50px;
  border: 1px dotted black;
  overflow: hidden;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Overflow</h2>
<div>You can use the overflow property when you want to have better control of the layout. The overflow property specifies what happens if content overflows an element's box. Searching "Overflow_Hide" word ctrl-F shows it is still present in the html page.</div>
</body>
</html>

标签: htmlcss

解决方案


推荐阅读