<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Single Line Text Example</title>
<!-- <style>
.single-line-text {
overflow: hidden;
width: 200px;
white-space: nowrap; /* 禁止文字换行 */
text-overflow: ellipsis; /* 使用省略号表示被隐藏的文字 */
}
</style> -->
<style>
.single-line-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 300px
}
</style>
</head>
<body>
<div class="single-line-text">
This is a long text that will be truncated if it exceeds the width of the container.
</div>
</body>
</html>
CSS单行文本省略(text-overflow:ellipsis/overflow:hidden/white-space:nowrap)
最新推荐文章于 2024-08-23 11:10:08 发布